getsentry / sentry-ruby

Sentry SDK for Ruby
https://sentry.io/for/ruby
MIT License
927 stars 493 forks source link

Custom extraction/injection of Sentry otel baggage #2264

Closed jscheid closed 6 months ago

jscheid commented 6 months ago

I'd like to use Sentry::OpenTelemetry::Propagator to extract baggage from, and inject baggage into, carriers other than HTTP headers. I seem to have this working for extraction, but when I try to re-inject the baggage into a fresh carrier it doesn't seem to work, nothing is added to the carrier.

I've tried both with and without creating a new span inside the extracted context, please see this test case:

https://gist.github.com/jscheid/9b685ebaaa0ab088c36a66059c33694f

This is probably due to faulty assumptions on my part -- can you spot what's wrong with my code?

jscheid commented 6 months ago

I'm fairly sure that this is caused by Sentry.start_transaction returning nil here. I'll try to work out why, or perhaps you can provide any clues?

jscheid commented 6 months ago

Sorry, this was due to a misconfiguration.

sl0thentr0py commented 6 months ago

oh i was about to investigate, but glad you figured it out! Can you also write briefly what the problem/fix was so that other people who land on this issue have a reference?

jscheid commented 6 months ago

Sentry::OpenTelemetry::Propagator.inject doesn't do anything (for imported contexts) unless Sentry.configuration.tracing_enabled? returns truthy, even if called explicitly like in my example. 😊