Skip to content

feat(core): Add isTracingSuppressed to the async context strategy#21785

Open
mydea wants to merge 1 commit into
developfrom
fn/is-tracing-suppressed-acs
Open

feat(core): Add isTracingSuppressed to the async context strategy#21785
mydea wants to merge 1 commit into
developfrom
fn/is-tracing-suppressed-acs

Conversation

@mydea

@mydea mydea commented Jun 25, 2026

Copy link
Copy Markdown
Member

Exposes a public isTracingSuppressed helper from @sentry/core and routes it through the async context strategy, mirroring suppressTracing.

Previously isTracingSuppressed only 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 with suppressTracing. Routing through the async context strategy keeps the two consistent across runtimes.

Changes

  • @sentry/core: export isTracingSuppressed, which delegates to acs.isTracingSuppressed and falls back to the scope-metadata check. Added isTracingSuppressed to the AsyncContextStrategy type and replaced the private _isTracingSuppressed usages.
  • @sentry/opentelemetry: implement isTracingSuppressed (reads the active OTel context) and register it on the async context strategy.
  • @sentry/node-core: SentryHttpInstrumentation and SentryNodeFetchInstrumentation now call core's isTracingSuppressed() instead of importing it from @opentelemetry/core.
  • Added unit tests in @sentry/core and @sentry/opentelemetry.

🤖 Generated with Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 620084c. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this is the safer approach, if that is missing.

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.47 kB - -
@sentry/browser - with treeshaking flags 25.91 kB - -
@sentry/browser (incl. Tracing) 45.99 kB +0.06% +24 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 47.74 kB +0.05% +22 B 🔺
@sentry/browser (incl. Tracing, Profiling) 50.78 kB +0.05% +23 B 🔺
@sentry/browser (incl. Tracing, Replay) 85.24 kB +0.03% +25 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.84 kB +0.04% +26 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 89.94 kB +0.03% +25 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 102.6 kB +0.03% +26 B 🔺
@sentry/browser (incl. Feedback) 44.66 kB - -
@sentry/browser (incl. sendFeedback) 32.26 kB - -
@sentry/browser (incl. FeedbackAsync) 37.4 kB - -
@sentry/browser (incl. Metrics) 28.54 kB - -
@sentry/browser (incl. Logs) 28.78 kB - -
@sentry/browser (incl. Metrics & Logs) 29.47 kB - -
@sentry/react 29.27 kB - -
@sentry/react (incl. Tracing) 48.3 kB +0.06% +27 B 🔺
@sentry/vue 32.65 kB +0.08% +26 B 🔺
@sentry/vue (incl. Tracing) 47.86 kB +0.05% +23 B 🔺
@sentry/svelte 27.5 kB - -
CDN Bundle 29.89 kB - -
CDN Bundle (incl. Tracing) 47.92 kB +0.07% +30 B 🔺
CDN Bundle (incl. Logs, Metrics) 31.44 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.27 kB +0.06% +29 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 70.78 kB - -
CDN Bundle (incl. Tracing, Replay) 85.42 kB +0.03% +22 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.7 kB +0.03% +22 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 91.21 kB +0.03% +21 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.47 kB +0.03% +21 B 🔺
CDN Bundle - uncompressed 88.94 kB - -
CDN Bundle (incl. Tracing) - uncompressed 145.09 kB +0.05% +66 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 93.65 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 149.06 kB +0.05% +66 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.62 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.11 kB +0.03% +66 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.07 kB +0.03% +66 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.81 kB +0.03% +66 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.76 kB +0.03% +66 B 🔺
@sentry/nextjs (client) 50.69 kB +0.05% +22 B 🔺
@sentry/sveltekit (client) 46.39 kB +0.05% +23 B 🔺
@sentry/core/server 77.49 kB +0.05% +33 B 🔺
@sentry/core/browser 63.84 kB +0.06% +33 B 🔺
@sentry/node-core 61.54 kB +0.06% +32 B 🔺
@sentry/node 124.62 kB +0.03% +28 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.42 kB +0.05% +22 B 🔺
@sentry/node - without tracing 73.64 kB +0.04% +28 B 🔺
@sentry/aws-serverless 84.44 kB +0.06% +43 B 🔺
@sentry/cloudflare (withSentry) - minified 180.37 kB +0.04% +61 B 🔺
@sentry/cloudflare (withSentry) 446.36 kB +0.03% +124 B 🔺

View base workflow run

@mydea mydea force-pushed the fn/is-tracing-suppressed-acs branch 3 times, most recently from 07d7a16 to d08ce0b Compare June 25, 2026 13:17
@mydea mydea marked this pull request as ready for review June 25, 2026 13:33
@mydea mydea requested a review from a team as a code owner June 25, 2026 13:33
@mydea mydea requested review from JPeer264 and andreiborza and removed request for a team June 25, 2026 13:33
Comment thread packages/opentelemetry/src/utils/suppressTracing.ts
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>
@mydea mydea force-pushed the fn/is-tracing-suppressed-acs branch from d08ce0b to a2229b7 Compare June 26, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant