fix: structured stacktrace capture in Ruby observability plugin#427
Merged
ccschmitz-launchdarkly merged 8 commits intomainfrom Mar 26, 2026
Merged
Conversation
…tput Expose `LaunchDarklyObservability.logger` so Sinatra, Grape, and plain Ruby applications get a logger that writes to a local IO (e.g. $stdout) and exports every entry as an OTLP LogRecord with trace/span correlation. The OtelLogBridge now accepts an optional `io:` parameter to support this dual-output mode while preserving the existing broadcast-only behavior used by the Rails integration.
sdk/@launchdarkly/observability-ruby/lib/launchdarkly_observability/otel_log_bridge.rb
Outdated
Show resolved
Hide resolved
SpennyNDaJets
approved these changes
Mar 25, 2026
Contributor
SpennyNDaJets
left a comment
There was a problem hiding this comment.
Code makes sense to me!
sdk/@launchdarkly/observability-ruby/lib/launchdarkly_observability/otel_log_bridge.rb
Outdated
Show resolved
Hide resolved
sdk/@launchdarkly/observability-ruby/lib/launchdarkly_observability/middleware.rb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
sdk/@launchdarkly/observability-ruby/lib/launchdarkly_observability/otel_log_bridge.rb
Show resolved
Hide resolved
… ccschmitz/ruby-o11y-plugin-improvements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Improve the Ruby observability plugin in two areas:
Middlewareand the Railsrecord_launchdarkly_exceptionhelper now attach anexception.structured_stacktraceJSON attribute (viaSourceContext.build_structured_stacktrace) when recording exceptions on spans. This enables richer error display in the observability UI.LaunchDarklyObservability.loggermodule method returns anOtelLogBridgethat writes to both a local IO (e.g.$stdout) and the OTel Logs pipeline with trace/span correlation. Falls back to a plainLoggerif the OTel logger provider isn't available yet. TheOtelLogBridgenow accepts an optionalio:parameter and propagates level/formatter changes to the local logger.The Sinatra demo app is updated to use the new logger, and the demo
Gemfile.lockpicks up the OpenTelemetry log exporter/SDK dependencies.How did you test this change?
LaunchDarklyObservability.loggercovering OTel bridge return, plain Logger fallback, and IO output verification (module_methods_test.rb)OtelLogBridgedual-output mode covering IO + OTel emission, OTel-only mode, level propagation, and hash message handling (otel_log_bridge_test.rb)Are there any deployment considerations?
None. These are additive changes to the Ruby gem with no breaking API changes.
Note
Low Risk
Low risk: changes are additive and primarily enrich telemetry (extra exception attributes and optional dual-output logging) without altering core SDK behavior or request handling flow.
Overview
Adds a new
LaunchDarklyObservability.loggerhelper for non-Rails apps that returns anOtelLogBridgecapable of writing to a local IO (e.g.$stdout) and exporting OTLP log records with trace/span correlation, falling back to a plainLoggerif the OTel logger provider isn’t ready.Improves exception telemetry by consistently attaching a JSON
exception.structured_stacktraceattribute when recording exceptions (modulerecord_exception, RackMiddleware, and Railsrecord_launchdarkly_exception) via a newSourceContext.exception_attributeshelper, and expands tests/docs/demo app accordingly (including adding OTLP logs dependencies in the Sinatra demo lockfile).Written by Cursor Bugbot for commit d345ed5. This will update automatically on new commits. Configure here.