You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/javascript/common/configuration/filtering.mdx
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -176,9 +176,8 @@ Learn more about <PlatformLink to="/configuration/sampling/">configuring the sam
176
176
177
177
## Filtering Spans
178
178
179
-
Available since JavaScript SDK version `8.2.0`.
180
-
181
179
Use the <PlatformIdentifiername="before-send-span" /> configuration option which allows you to provide a function to modify a span.
182
180
This function is called for the root span and all child spans. If you want to drop the root span, including its child spans, use [`beforeSendTransaction`](#using-beforesendtransaction) instead.
181
+
Please note that you cannot use `beforeSendSpan` to drop a span, you can only modify it and filter data on it.
Copy file name to clipboardExpand all lines: docs/platforms/javascript/common/tracing/configure-sampling/index.mdx
+11-10Lines changed: 11 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,18 +6,20 @@ sidebar_order: 30
6
6
7
7
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.
8
8
9
-
## Sampling Configuration Options
10
-
11
9
The JavaScript SDK provides two main options for controlling the sampling rate:
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.
19
21
20
-
###Sampling Function (`tracesSampler`)
22
+
## Sampling Function (`tracesSampler`)
21
23
22
24
For more granular control, you provide a `tracesSampler` function. This approach allows you to:
23
25
@@ -36,16 +38,16 @@ When the `tracesSampler` function is called, it receives a `samplingContext` obj
36
38
interfaceSamplingContext {
37
39
// Name of the span/transaction
38
40
name:string;
39
-
41
+
40
42
// Initial attributes of the span/transaction
41
43
attributes:SpanAttributes|undefined;
42
-
44
+
43
45
// Whether the parent span was sampled (undefined if no incoming trace)
44
46
parentSampled:boolean|undefined;
45
-
47
+
46
48
// Sample rate from incoming trace (undefined if no incoming trace)
47
49
parentSampleRate:number|undefined;
48
-
50
+
49
51
// Utility function to inherit parent decision or fallback
When multiple sampling mechanisms could apply, Sentry follows this order of precedence:
127
129
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.
129
131
- If no `tracesSampler` is defined, but there is a parent sampling decision from an incoming distributed trace, we use the parent sampling decision
130
132
- If neither of the above, `tracesSampleRate` is used
131
133
- 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
134
136
## Conclusion
135
137
136
138
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.
See <PlatformLinkto="/tracing/instrumentation/automatic-instrumentation">Automatic Instrumentation</PlatformLink> to learn about all the things that the SDK automatically instruments for you.
69
+
See <PlatformLinkto="/tracing/instrumentation/automatic-instrumentation">Automatic Instrumentation</PlatformLink> to learn about all the things that the SDK automatically instruments for you.
70
+
70
71
</PlatformSection>
71
72
72
73
## Custom Instrumentation
73
74
74
75
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.
75
76
76
-
See <PlatformLinkto="/tracing/span-metrics/">Sending Span Metrics</PlatformLink> to learn how to manually start spans.
0 commit comments