Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(opentelemetry)!: Simplify propagation and remove custom OTel tracing utils#22702
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
0df122c19d37d8aa90c890166d24d3b91f35c0580d313d70f2efb18465c8a4c5d24bc4302be743e353a461517d103fa4f1451cbac0fc26a8File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -257,8 +257,7 @@ export const continueTrace = <V>( | ||
| return withScope(scope => { | ||
| const propagationContext = propagationContextFromHeaders(sentryTrace, baggage); | ||
| scope.setPropagationContext(propagationContext); | ||
| _setSpanForScope(scope, undefined); | ||
| return callback(); | ||
| return withActiveSpan(null, callback); | ||
| }); | ||
| }; | ||
| @@ -330,13 +329,15 @@ export function startNewTrace<T>(callback: () => T): T { | ||
| return acs.startNewTrace(callback); | ||
| } | ||
| return withScope(scope => { | ||
| scope.setPropagationContext({ | ||
| traceId: generateTraceId(), | ||
| sampleRand: safeMathRandom(), | ||
| return withActiveSpan(null, () => { | ||
MemberAuthor 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. just switching this up, it should not make concrete difference but seems more resilient, as it makes us more independent of what | ||
| return withScope(scope => { | ||
| scope.setPropagationContext({ | ||
| traceId: generateTraceId(), | ||
| sampleRand: safeMathRandom(), | ||
| }); | ||
| DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`); | ||
| return callback(); | ||
| }); | ||
| DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`); | ||
| return withActiveSpan(null, callback); | ||
| }); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import * as os from 'node:os'; | ||
| import type { Tracer } from '@opentelemetry/api'; | ||
| import { trace } from '@opentelemetry/api'; | ||
| import type { DynamicSamplingContext, Scope, ServerRuntimeClientOptions, TraceContext } from '@sentry/core'; | ||
| import type { ServerRuntimeClientOptions } from '@sentry/core'; | ||
| import { | ||
| _INTERNAL_clearAiProviderSkips, | ||
| _INTERNAL_flushLogsBuffer, | ||
| @@ -11,11 +11,7 @@ import { | ||
| SDK_VERSION, | ||
| ServerRuntimeClient, | ||
| } from '@sentry/core'; | ||
| import { | ||
| type AsyncLocalStorageLookup, | ||
| getTraceContextForScope, | ||
| type SentryTracerProvider, | ||
| } from '@sentry/opentelemetry'; | ||
| import { type AsyncLocalStorageLookup, type SentryTracerProvider } from '@sentry/opentelemetry'; | ||
| import { isMainThread, threadId } from 'worker_threads'; | ||
| import { DEBUG_BUILD } from '../debug-build'; | ||
| import type { NodeClientOptions } from '../types'; | ||
| @@ -170,15 +166,4 @@ export class NodeClient extends ServerRuntimeClient<NodeClientOptions> { | ||
| _INTERNAL_clearAiProviderSkips(); | ||
| super._setupIntegrations(); | ||
| } | ||
| /** Custom implementation for OTEL, so we can handle scope-span linking. */ | ||
| protected _getTraceInfoFromScope( | ||
MemberAuthor 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. it seems this was not used anywhere anymore! | ||
| scope: Scope | undefined, | ||
| ): [dynamicSamplingContext: Partial<DynamicSamplingContext> | undefined, traceContext: TraceContext | undefined] { | ||
| if (!scope) { | ||
| return [undefined, undefined]; | ||
| } | ||
| return getTraceContextForScope(this, scope); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -18,11 +18,10 @@ import { | ||
| SENTRY_FORK_SET_SCOPE_CONTEXT_KEY, | ||
| SENTRY_TRACE_STATE_CHILD_IGNORED, | ||
| } from './constants'; | ||
| import { continueTrace, startInactiveSpan, startNewTrace, startSpan, startSpanManual, withActiveSpan } from './trace'; | ||
| import { startInactiveSpan, startSpan, startSpanManual, withActiveSpan } from './trace'; | ||
| import type { CurrentScopes } from './types'; | ||
| import { getContextFromScope, getScopesFromContext } from './utils/contextData'; | ||
| import { getActiveSpan } from './utils/getActiveSpan'; | ||
| import { getTraceData } from './utils/getTraceData'; | ||
| import { AsyncLocalStorage } from 'node:async_hooks'; | ||
| import type { AsyncLocalStorageLookup } from './asyncLocalStorageContextManager'; | ||
| import { SentryAsyncLocalStorageContextManager } from './asyncLocalStorageContextManager'; | ||
| @@ -144,9 +143,6 @@ export function setOpenTelemetryContextAsyncContextStrategy(): AsyncLocalStorage | ||
| startSpanManual, | ||
| startInactiveSpan, | ||
| getActiveSpan, | ||
| getTraceData, | ||
| continueTrace, | ||
| startNewTrace, | ||
cursor[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // The types here don't fully align, because our own `Span` type is narrower | ||
| // than the OTEL one - but this is OK for here, as we now we'll only have OTEL spans passed around | ||
| withActiveSpan: withActiveSpan, | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| export { getScopesFromContext } from './utils/contextData'; | ||
| export { getTraceContextForScope } from './trace'; | ||
cursor[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| export { setupEventContextTrace } from './setupEventContextTrace'; | ||
| export { SentryPropagator } from './propagator'; | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.