feat(core): Add isTracingSuppressed to the async context strategy#21785
feat(core): Add isTracingSuppressed to the async context strategy#21785mydea wants to merge 1 commit into
isTracingSuppressed to the async context strategy#21785Conversation
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, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 620084c. Configure here.
|
|
||
| export function isTracingSuppressed(scope?: Scope): boolean { | ||
| const ctx = scope ? getContextFromScope(scope) : context.active(); | ||
| return ctx ? isTracingSuppressedImpl(ctx) : false; |
There was a problem hiding this comment.
Missing active context fallback
Medium Severity
The OpenTelemetry isTracingSuppressed helper returns false when getContextFromScope(scope) is missing, instead of falling back to context.active(). Node HTTP/fetch instrumentation now uses this path rather than checking the active OTel context directly, so suppression can be missed and outgoing spans or trace headers may still be created.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 620084c. Configure here.
There was a problem hiding this comment.
IMHO this is the safer approach, if that is missing.
size-limit report 📦
|
07d7a16 to
d08ce0b
Compare
Expose a public `isTracingSuppressed` helper from `@sentry/core` that delegates to the async context strategy (falling back to the scope's SDK processing metadata), mirroring how `suppressTracing` works. This lets OTel-based SDKs answer suppression from the active OpenTelemetry context rather than only the scope metadata, keeping `isTracingSuppressed` consistent with `suppressTracing`. - core: export `isTracingSuppressed`, add it to the `AsyncContextStrategy` type, and replace the private `_isTracingSuppressed` usages. - opentelemetry: implement `isTracingSuppressed` (reads the OTel context) and register it on the async context strategy. - node-core: `SentryHttpInstrumentation` and `SentryNodeFetchInstrumentation` now use core's `isTracingSuppressed()` instead of importing from `@opentelemetry/core`. - Add unit tests in core and opentelemetry. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
d08ce0b to
a2229b7
Compare


Exposes a public
isTracingSuppressedhelper from@sentry/coreand routes it through the async context strategy, mirroringsuppressTracing.Previously
isTracingSuppressedonly existed as a private helper that checked the scope's SDK processing metadata. That's correct for the core (stack) strategy, but on OTel-based SDKs (e.g. Node) tracing suppression lives on the active OpenTelemetry context — so a metadata-only check could disagree withsuppressTracing. Routing through the async context strategy keeps the two consistent across runtimes.Changes
@sentry/core: exportisTracingSuppressed, which delegates toacs.isTracingSuppressedand falls back to the scope-metadata check. AddedisTracingSuppressedto theAsyncContextStrategytype and replaced the private_isTracingSuppressedusages.@sentry/opentelemetry: implementisTracingSuppressed(reads the active OTel context) and register it on the async context strategy.@sentry/node-core:SentryHttpInstrumentationandSentryNodeFetchInstrumentationnow call core'sisTracingSuppressed()instead of importing it from@opentelemetry/core.@sentry/coreand@sentry/opentelemetry.🤖 Generated with Claude Code