-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
docs(js): Add docs for strictTraceContinuation
and orgId
#14459
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
Changes from 2 commits
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 |
---|---|---|
|
@@ -379,6 +379,31 @@ If you want to disable trace propagation, you can set this option to `[]`. | |
|
||
</SdkOption> | ||
|
||
|
||
<PlatformCategorySection supported={["server", "serverless"]}> | ||
<SdkOption name="strictTraceContinuation" type='boolean' defaultValue='false'> | ||
|
||
If set to `true`, the SDK will only continue a trace if the organization ID of the incoming trace found in the | ||
`baggage` header matches the organization ID of the current Sentry client. | ||
|
||
The client's organization ID is extracted from the DSN or can be set with the `orgId` option. | ||
|
||
If the organization IDs do not match, the SDK will start a new trace instead of continuing the incoming one. | ||
This is useful to prevent traces of unknown third-party services from being continued in your application. | ||
|
||
</SdkOption> | ||
|
||
<SdkOption name="orgId" type='`${number}` | number'> | ||
|
||
The organization ID for your Sentry project. | ||
|
||
The SDK will try to extract the organization ID from the DSN. If it cannot be found, or if you need to override it, | ||
you can provide the ID with this option. The organization ID is used for trace propagation and for features like `strictTraceContinuation`. | ||
|
||
</SdkOption> | ||
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. As stated in the PR description: I am not 100% sure where we should put 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's fine. Or move it below DSN. 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. I agree! |
||
|
||
</PlatformCategorySection> | ||
|
||
<PlatformCategorySection supported={['browser']}> | ||
|
||
<SdkOption name="beforeSendTransaction" type='(event: TransactionEvent, hint: EventHint) => TransactionEvent | null'> | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -71,6 +71,39 @@ This configuration lets your app track user actions across: | |||||
|
||||||
If your app crashes while a user is uploading a photo, you can trace exactly where the problem occurred - in the app itself, the main API, or the media service. | ||||||
|
||||||
### Strict Trace Continuation | ||||||
|
||||||
_Available since SDK version 10_ | ||||||
|
||||||
When your application receives requests, they might include `sentry-trace` and `baggage` headers from an upstream service that is also using Sentry. | ||||||
By default, the SDK will continue the trace from the incoming headers. This can be undesirable if the requests are from a third-party service, | ||||||
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.
Suggested change
|
||||||
as it can lead to unwanted traces, increased billing, and skewed performance data. | ||||||
|
||||||
To prevent this, you can enable `strictTraceContinuation`. When this option is set to `true`, the SDK checks the incoming request for Sentry trace information. | ||||||
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.
Suggested change
|
||||||
It only continues the trace if it belongs to the same Sentry organization. Otherwise, it starts a new trace. | ||||||
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.
Suggested change
|
||||||
This is useful if your application is a public API or receives requests from services outside your organization. | ||||||
|
||||||
```javascript {5} | ||||||
Sentry.init({ | ||||||
dsn: "___PUBLIC_DSN___", | ||||||
tracesSampleRate: 1.0, | ||||||
// Ensure that only traces from your own organization are continued | ||||||
strictTraceContinuation: true, | ||||||
}); | ||||||
``` | ||||||
|
||||||
The SDK automatically parses the organization ID from your DSN. If you use a DSN format that doesn't include the organization ID (number followed by the letter `"o"`), or if you need to override it, you can provide it manually using the `orgId` option: | ||||||
|
||||||
```javascript {6} | ||||||
Sentry.init({ | ||||||
dsn: "___PUBLIC_DSN___", | ||||||
tracesSampleRate: 1.0, | ||||||
strictTraceContinuation: true, | ||||||
// Manually provide your organization ID (overrides organization ID parsed from DSN) | ||||||
orgId: 12345, | ||||||
}); | ||||||
``` | ||||||
|
||||||
### Disabling Distributed Tracing | ||||||
|
||||||
If you want to disable distributed tracing and ensure no Sentry trace headers are sent, you can configure your SDK like this: | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.