-
-
Notifications
You must be signed in to change notification settings - Fork 525
Add external_propagation_context support #2841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,19 +60,10 @@ def apply_to_event(event, hint = nil) | |
| event.attachments = attachments | ||
| end | ||
|
|
||
| if span | ||
| event.contexts[:trace] ||= span.get_trace_context | ||
|
|
||
| if event.respond_to?(:dynamic_sampling_context) | ||
| event.dynamic_sampling_context ||= span.get_dynamic_sampling_context | ||
| end | ||
| else | ||
| event.contexts[:trace] ||= propagation_context.get_trace_context | ||
|
|
||
| if event.respond_to?(:dynamic_sampling_context) | ||
| event.dynamic_sampling_context ||= propagation_context.get_dynamic_sampling_context | ||
| end | ||
| end | ||
| trace_context = get_trace_context | ||
| dynamic_sampling_context = trace_context.delete(:dynamic_sampling_context) | ||
| event.contexts[:trace] ||= trace_context | ||
| event.dynamic_sampling_context ||= dynamic_sampling_context | ||
|
|
||
| all_event_processors = self.class.global_event_processors + @event_processors | ||
|
|
||
|
|
@@ -94,7 +85,7 @@ def apply_to_event(event, hint = nil) | |
| # @return [MetricEvent, LogEvent] the telemetry event with scope context applied | ||
| def apply_to_telemetry(telemetry) | ||
| # TODO-neel when new scope set_attribute api is added: add them here | ||
| trace_context = span ? span.get_trace_context : propagation_context.get_trace_context | ||
| trace_context = get_trace_context | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be an overkill because we're building up a bunch of hashes just to get trace_id and span_id - it would be better to have something more dedicated to get these two values.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its one hash, its fine because all these values belong together, they are not separate
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its one hash, its fine because all these values belong together, they are not separate |
||
| telemetry.trace_id = trace_context[:trace_id] | ||
| telemetry.span_id = trace_context[:span_id] | ||
|
|
||
|
|
@@ -305,6 +296,20 @@ def get_span | |
| span | ||
| end | ||
|
|
||
| # Returns the trace context for this scope. | ||
| # Prioritizes external propagation context (from OTel) over local propagation context. | ||
| # @return [Hash] | ||
| def get_trace_context | ||
| if span | ||
| span.get_trace_context.merge(dynamic_sampling_context: span.get_dynamic_sampling_context) | ||
| elsif (external_context = Sentry.get_external_propagation_context) | ||
| trace_id, span_id = external_context | ||
| { trace_id: trace_id, span_id: span_id } | ||
| else | ||
| propagation_context.get_trace_context.merge(dynamic_sampling_context: propagation_context.get_dynamic_sampling_context) | ||
| end | ||
| end | ||
sl0thentr0py marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Sets the scope's fingerprint attribute. | ||
| # @param fingerprint [Array] | ||
| # @return [Array] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.