Skip to content

Commit f766838

Browse files
mydeacodydes1gr1d
authored
ref(js): Small fixes to configure sampling structure (#13230)
* ref(js): Small fixes to configure sampling structure * Update docs/platforms/javascript/common/tracing/configure-sampling/index.mdx Co-authored-by: Sigrid Huemer <[email protected]> --------- Co-authored-by: Cody De Arkland <[email protected]> Co-authored-by: Sigrid Huemer <[email protected]>
1 parent ef62537 commit f766838

File tree

1 file changed

+11
-10
lines changed
  • docs/platforms/javascript/common/tracing/configure-sampling

1 file changed

+11
-10
lines changed

docs/platforms/javascript/common/tracing/configure-sampling/index.mdx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ sidebar_order: 30
66

77
Sentry's tracing functionality helps you monitor application performance by capturing distributed traces, attaching attributes, and span performance across your application. However, Capturing traces for every transaction can generate significant volumes of data. Sampling allows you to control the amount of spans that are sent to Sentry from your application.
88

9-
## Sampling Configuration Options
10-
119
The JavaScript SDK provides two main options for controlling the sampling rate:
1210

13-
1. Uniform Sample Rate (`tracesSampleRate`)
11+
1. [Uniform Sample Rate](#uniform-sample-rate-tracessamplerate) (recommended)
12+
2. [Sampling Function](#sampling-function-tracessampler)
13+
14+
## Uniform Sample Rate (`tracesSampleRate`)
15+
1416
`tracesSampleRate` is floating point value 0.0 and 1.0, which controls the probability that a transaction will be sampled.
1517

1618
<PlatformContent includePath="/tracing/sample-rate" />
1719

1820
With `tracesSampleRate` set to `0.25`, each transaction in your application is randomly sampled with a probability of 25%, so you can expect that one in every four transactions will be sent to Sentry.
1921

20-
### Sampling Function (`tracesSampler`)
22+
## Sampling Function (`tracesSampler`)
2123

2224
For more granular control, you provide a `tracesSampler` function. This approach allows you to:
2325

@@ -36,16 +38,16 @@ When the `tracesSampler` function is called, it receives a `samplingContext` obj
3638
interface SamplingContext {
3739
// Name of the span/transaction
3840
name: string;
39-
41+
4042
// Initial attributes of the span/transaction
4143
attributes: SpanAttributes | undefined;
42-
44+
4345
// Whether the parent span was sampled (undefined if no incoming trace)
4446
parentSampled: boolean | undefined;
45-
47+
4648
// Sample rate from incoming trace (undefined if no incoming trace)
4749
parentSampleRate: number | undefined;
48-
50+
4951
// Utility function to inherit parent decision or fallback
5052
inheritOrSampleWith: (fallbackRate: number) => number;
5153
}
@@ -125,7 +127,7 @@ tracesSampler: (samplingContext) => {
125127
126128
When multiple sampling mechanisms could apply, Sentry follows this order of precedence:
127129
128-
- If `tracesSampler` is defined, its decision is used. Although the `tracesSampler` can override the parent sampling decision, most users will want to ensure their `tracesSampler` respects the parent sampling decision.
130+
- If `tracesSampler` is defined, its decision is used. Although the `tracesSampler` can override the parent sampling decision, most users will want to ensure their `tracesSampler` respects the parent sampling decision.
129131
- If no `tracesSampler` is defined, but there is a parent sampling decision from an incoming distributed trace, we use the parent sampling decision
130132
- If neither of the above, `tracesSampleRate` is used
131133
- If `tracesSampleRate` is set to 0, no spans will be sampled, and no downstream spans will be sampled either since they inherit the parent sampling decision
@@ -134,4 +136,3 @@ When multiple sampling mechanisms could apply, Sentry follows this order of prec
134136
## Conclusion
135137
136138
Effective sampling is key to getting the most value from Sentry's performance monitoring while minimizing overhead. The `tracesSampler` function gives you precise control over which transactions to record, allowing you to focus on the most important parts of your application.
137-

0 commit comments

Comments
 (0)