-
-
Notifications
You must be signed in to change notification settings - Fork 468
feat: Add strict trace continuation support #5136
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
base: main
Are you sure you want to change the base?
Changes from all commits
dc8d319
e550ae3
c272ee4
1cfc2ea
108eb2d
e30064c
4545735
61ada6a
519f6a6
360fc94
ea9f456
58bfc8e
ebe8c4c
824b30b
e2fdc46
d3b073d
f7fef22
71562fa
327d897
f1edc98
863f05b
1d8e301
25e71db
a3c86e7
3d1d119
bad469f
cf7d9fe
435d2e7
63222e5
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 |
|---|---|---|
|
|
@@ -113,6 +113,14 @@ public <C> Context extract( | |
|
|
||
| final @Nullable String baggageString = getter.get(carrier, BaggageHeader.BAGGAGE_HEADER); | ||
| final Baggage baggage = Baggage.fromHeader(baggageString); | ||
| if (!TracingUtils.shouldContinueTrace(scopes.getOptions(), baggage)) { | ||
| scopes | ||
| .getOptions() | ||
| .getLogger() | ||
| .log( | ||
| SentryLevel.DEBUG, "Not continuing trace due to strict org ID validation failure."); | ||
| return context; | ||
| } | ||
|
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. OtelSentrySpanProcessor bypasses org ID trace validationMedium Severity The org ID check in |
||
| final @NotNull TraceState traceState = TraceState.getDefault(); | ||
|
|
||
| SpanContext otelSpanContext = | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package io.sentry.opentelemetry | ||
|
|
||
| import io.opentelemetry.api.trace.Span | ||
| import io.opentelemetry.context.Context | ||
| import io.sentry.IScopes | ||
| import io.sentry.SentryOptions | ||
| import io.sentry.opentelemetry.SentryOtelKeys.SENTRY_BAGGAGE_KEY | ||
| import io.sentry.opentelemetry.SentryOtelKeys.SENTRY_TRACE_KEY | ||
| import kotlin.test.Test | ||
| import kotlin.test.assertFalse | ||
| import kotlin.test.assertNull | ||
| import org.mockito.kotlin.mock | ||
| import org.mockito.kotlin.whenever | ||
|
|
||
| class SentryPropagatorTest { | ||
|
|
||
| @Suppress("DEPRECATION") | ||
| @Test | ||
| fun `ignores incoming headers when strict continuation rejects org id`() { | ||
| val options = | ||
| SentryOptions().apply { | ||
| dsn = "https://key@o2.ingest.sentry.io/123" | ||
| isStrictTraceContinuation = true | ||
| } | ||
| val scopes = mock<IScopes>() | ||
| whenever(scopes.options).thenReturn(options) | ||
|
|
||
| val propagator = SentryPropagator(scopes) | ||
| val carrier: Map<String, String> = | ||
| mapOf( | ||
| "sentry-trace" to "f9118105af4a2d42b4124532cd1065ff-424cffc8f94feeee-1", | ||
| "baggage" to "sentry-trace_id=f9118105af4a2d42b4124532cd1065ff,sentry-org_id=1", | ||
| ) | ||
|
|
||
| val newContext = propagator.extract(Context.root(), carrier, MapGetter()) | ||
|
|
||
| assertFalse(Span.fromContext(newContext).spanContext.isValid) | ||
| assertNull(newContext.get(SENTRY_TRACE_KEY)) | ||
| assertNull(newContext.get(SENTRY_BAGGAGE_KEY)) | ||
| } | ||
| } |


Uh oh!
There was an error while loading. Please reload this page.