Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tracing): Add hook for trace sampling function to SDK options (#…
…2820) Currently, tracing is either on, with a static sample rate for all transactions, or off. This doesn't let users either a) sample different transactions at different rates or b) filter out certain transactions all together. This PR introduces a new SDK option, `tracesSampler`, whose value is a callback with the signature `tracesSampler(samplingContext: SamplingContext): number | boolean`, where `samplingContext` is a combination of automatically-provided data (varying by SDK/integration) and data passed by the user to `startTransaction()` as an optional third parameter. Given that data, the `tracesSampler` function can then compute the appropriate sample rate and return it to the sampling function. Example use cases for variable sample rate: - Collect traces for all enterprise customers but only a fraction of regular customers - Collect a higher percentage of traces on rarely-visited pages, to ensure a decent sample size - Collect more traces on a page you recently revamped compared to one whose code you already have well-profiled Example use cases for filtering: - Don't trace pre-flight CORS requests - Don't trace health check requests - Don't collect traces from users with a certain browser extension enabled, because it's known to break things - Don't trace navigation to deprecated parts of your web app (A user can, of course, combine these ideas as well, returning a variable sample rate for some traces and 0 to filter out others.) In order to support this addition, a few other changes needed to be made: - Move method for extracting node request data to `@sentry/utils` - Break up `misc.ts` to eliminate circular dependencies within `@sentry/utils` - Move method for extracting `sentry-trace` data into `@sentry/tracing` utils - Tweak some types related to domains and request data, and polyfill `WorkerLocation` type
- Loading branch information
1 parent
f398514
commit 7c14283
Showing
32 changed files
with
1,134 additions
and
436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
export { Carrier, Layer } from './interfaces'; | ||
export { Carrier, DomainAsCarrier, Layer } from './interfaces'; | ||
export { addGlobalEventProcessor, Scope } from './scope'; | ||
export { getCurrentHub, getHubFromCarrier, getMainCarrier, Hub, makeMain, setHubOnCarrier } from './hub'; | ||
export { | ||
getActiveDomain, | ||
getCurrentHub, | ||
getHubFromCarrier, | ||
getMainCarrier, | ||
Hub, | ||
makeMain, | ||
setHubOnCarrier, | ||
} from './hub'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.