Skip to content

Commit 6d50a9c

Browse files
author
Luca Forstner
committed
Update to new api
1 parent 89e1656 commit 6d50a9c

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

docs/platforms/javascript/common/configuration/sampling.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ The Sentry SDKs have two configuration options to control the volume of transact
4242

4343
2. Sampling function (<PlatformIdentifier name="traces-sampler" />) which:
4444
- Samples different transactions at different rates
45-
- <PlatformLink to="/configuration/filtering/">Filters</PlatformLink> out some
46-
transactions entirely
45+
- <PlatformLink to="/configuration/filtering/">Filters</PlatformLink> out
46+
some transactions entirely
4747
- Modifies default [precedence](#precedence) and [inheritance](#inheritance) behavior
4848

4949
By default, none of these options are set, meaning no transactions will be sent to Sentry. You must set either one of the options to start sending transactions.
@@ -98,7 +98,6 @@ There are multiple ways for a transaction to end up with a sampling decision.
9898

9999
When there's the potential for more than one of these to come into play, the following precedence rules apply:
100100

101-
1. If a sampling decision is passed to <PlatformIdentifier name="start-transaction" />, that decision will be used, overriding everything else.
102101
1. If <PlatformIdentifier name="traces-sampler" /> is defined, its decision will be used. It can choose to keep or ignore any parent sampling decision, use the sampling context data to make its own decision, or choose a sample rate for the transaction. We advise against overriding the parent sampling decision because it will break distributed traces)
103102
1. If <PlatformIdentifier name="traces-sampler" /> is not defined, but there's a parent sampling decision, the parent sampling decision will be used.
104103
1. If <PlatformIdentifier name="traces-sampler" /> is not defined and there's no parent sampling decision, <PlatformIdentifier name="traces-sample-rate" /> will be used.

platform-includes/performance/traces-sampler-as-sampler/javascript.mdx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface SamplingContext {
1414
Sentry.init({
1515
// ...
1616

17-
tracesSampler: ({ name, attributes, parentSampled }) => {
17+
tracesSampler: ({ name, attributes, inheritOrSampleWith }) => {
1818
// Do not sample health checks ever
1919
if (name.includes("healthcheck")) {
2020
return 0;
@@ -30,24 +30,17 @@ Sentry.init({
3030
return 0.01;
3131
}
3232

33-
// Inherit the samle rate of the incoming trace if there is one. Sampling is deterministic
34-
// for one entire trace, i.e. if the parent was sampled, we will be sampled too at the same
35-
// rate.
36-
if (typeof parentSampleRate === "number") {
37-
return parentSampleRate;
38-
}
39-
40-
// Else, use default sample rate
41-
return 0.5;
33+
// Otherwise, inherit the sample sampling decision of the incoming trace, or use a fallback sampling rate.
34+
return inheritOrSampleWith(0.5);
4235
},
4336
});
4437
```
4538

4639
<Alert title="parentSampleRate">
4740

48-
The `parentSampleRate` sampling context was introduced in version 9 of the SDK.
49-
To inherit sampling decisions in earlier versions of the SDK, us the `parentSampled` sampling context.
41+
The `inheritOrSampleWith` sampling context utility was introduced in version 9 of the SDK.
42+
To inherit sampling decisions in earlier versions of the SDK, use the `parentSampled` sampling context.
5043

51-
Going forward, using `parentSampleRate` is strongly encouraged over using `parentSampled`, because it allows for deterministic sampling and metric extrapolation for downstream traces.
44+
Going forward, using `inheritOrSampleWith()` is strongly encouraged over using `parentSampled`, because it allows for deterministic sampling and metric extrapolation for downstream traces.
5245

5346
</Alert>

0 commit comments

Comments
 (0)