Skip to content

feat(js): Document how to disable tracing #14268

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

Merged
merged 3 commits into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Replacing this flag with `false` will tree shake any SDK code that's related to

<Alert>
`__SENTRY_TRACING__` must not be replaced with `false` when you're using any
tracing-related SDK features (for example,`Sentry.startTransaction()`). This
tracing-related SDK features (for example,`Sentry.startSpan()`). This
flag is intended to be used in combination with packages like `@sentry/next`
or `@sentry/sveltekit`, which automatically include the tracing functionality.
</Alert>
Expand Down
34 changes: 29 additions & 5 deletions docs/platforms/javascript/common/tracing/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ With [tracing](/product/insights/overview/), Sentry automatically tracks your so
## Configure

<PlatformSection supported={["javascript"]}>
Enable tracing by configuring the sampling rate for transactions. Set the
sample rate for your transactions by either:
Enable tracing by configuring the sampling rate for traces. Set the sample
rate as follows:
</PlatformSection>

<PlatformSection notSupported={["javascript"]}>
Enable tracing by setting the sample rate for your transactions.
Enable tracing by setting the sample rate for your traces.
</PlatformSection>

<PlatformContent includePath="performance/configure-sample-rate" />
Expand Down Expand Up @@ -75,13 +75,37 @@ See <PlatformLink to="/tracing/instrumentation/automatic-instrumentation">Automa

You can also manually start spans to instrument specific parts of your code. This is useful when you want to measure the performance of a specific operation or function.

- <PlatformLink to="/apis/#tracing">Tracing APIs</PlatformLink>:
Find information about APIs for custom tracing instrumentation
- <PlatformLink to="/apis/#tracing">Tracing APIs</PlatformLink>: Find
information about APIs for custom tracing instrumentation
- <PlatformLink to="/tracing/instrumentation/">Instrumentation</PlatformLink>:
Find information about manual instrumentation with the Sentry SDK
- <PlatformLink to="/tracing/span-metrics/">Sending Span Metrics</PlatformLink>:
Learn how to capture metrics on your spans

## Disabling Tracing

If you want to disable tracing, you _should not_ set `tracesSampleRate` at
Copy link
Collaborator

Choose a reason for hiding this comment

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

On the options page we also say "Either this or tracesSampler must be defined to enable tracing." (where "this" refers to tracesSampleRate)

It would make sense to me to mention the tracesSampler option here too

all. Setting it to `0` will not disable tracing, it will simply never send any
traces to Sentry.
Instead, neither `tracesSampleRate` nor `tracesSampler` should be defined in your SDK config to fully disable tracing.

<PlatformSection
supported={[
"javascript.nextjs",
"javascript.nuxt",
"javascript.sveltekit",
"javascript.astro",
"javascript.solidstart",
]}
>
In addition, you can set `__SENTRY_TRACING__` to `false` to ensure the tracing code
is removed from your production build. This will result in{" "}
<PlatformLink to="/tracing/distributed-tracing/">trace propagation</PlatformLink>{" "}
being disabled as well. See{" "}
<PlatformLink to="/configuration/tree-shaking/">Tree Shaking</PlatformLink>{" "}
for more information.
</PlatformSection>

## Next Steps

<PageGrid />