Skip to content

Commit d92a2eb

Browse files
docs(sdks): Span Sampling (#11940)
* docs(sdks): Span Sampling * Remove out-of-scope items * chore(wording): Apply RFC keywords MUST, SHOULD and MAY * chore(docs): split contents into separate files * chore(docs): indicate work in progress --------- Co-authored-by: Stephanie Anderson <[email protected]>
1 parent 7432e6c commit d92a2eb

File tree

4 files changed

+122
-0
lines changed

4 files changed

+122
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: Filtering
3+
---
4+
5+
<Alert level="warning">
6+
🚧 This document is work in progress.
7+
</Alert>
8+
9+
<Alert level="info">
10+
This document uses key words such as "MUST", "SHOULD", and "MAY" as defined in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt) to indicate requirement levels.
11+
</Alert>
12+
13+
The SDK MUST implement a mechanism for users to filter out spans.
14+
The result MUST be binary (`true` or `false`).
15+
Any APIs exposed to the user to filter spans MUST adhere to the following design principles:
16+
17+
- The APIs are optimized for trace completeness
18+
- The APIs are optimized for conclusive sampling decisions
19+
20+
## Filter with `ignoreSpans`
21+
22+
The `ignoreSpans` option accepts a glob pattern or string.
23+
24+
```js
25+
Sentry.init({
26+
ignoreSpans: [
27+
'GET /about',
28+
'events.signal *',
29+
]
30+
})
31+
```
32+
33+
## Filter with `integrations`
34+
35+
The `integrations` option MAY perform in similar fashion as the `ignoreSpans` option, or make explicit opt-out possible via a boolean flag.
36+
37+
```js
38+
Sentry.init({
39+
integrations: [
40+
fsIntegration: {
41+
ignoreSpans: [
42+
'fs.read',
43+
],
44+
readSpans: true,
45+
writeSpans: false,
46+
}
47+
]
48+
})
49+
```
50+
51+
## Other approaches
52+
53+
If both options mentioned above are not feasible to be implemented in certain SDKs, other approaches MUST be explored that have the same outcome.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Spans
3+
sidebar_order: 8
4+
---
5+
6+
<PageGrid />
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Sampling
3+
---
4+
5+
<Alert level="warning">
6+
🚧 This document is work in progress.
7+
</Alert>
8+
9+
<Alert level="info">
10+
This document uses key words such as "MUST", "SHOULD", and "MAY" as defined in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt) to indicate requirement levels.
11+
</Alert>
12+
13+
Any APIs exposed to the user to sample spans MUST adhere to the following design principles:
14+
15+
- Sampling MUST only happen to a root span
16+
- The APIs are optimized for trace completeness
17+
- The APIs are optimized for conclusive sampling decisions
18+
19+
## Sample with `tracesSampleRate`
20+
21+
The SDK is automatically initialized with a `tracesSampleRate` of `0.0`.
22+
When starting a root span, the configured rate is compared against a random number between `0.0` and `1.0` to decide if this root span will be sampled or not.
23+
24+
## Sample with `tracesSampler`
25+
26+
If the SDK is configured with a `tracesSampler`, the `tracesSampleRate` no longer applies.
27+
28+
The `tracesSampler` callback MUST receive sufficient arguments from users to define their own sampling rules.
29+
This MAY include but is not limited to certain attributes from the root span, such as HTTP headers.
30+
The return value of the `tracesSampler` is a float between `0.0` and `1.0`.
31+
32+
If no `tracesSampler` is configured, a propagated sampling decision via the traceparent takes precedence over the `tracesSampleRate`. This behavior MAY be disabled by defining a `tracesSampler`.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: Scrubbing data
3+
---
4+
5+
<Alert level="warning">
6+
🚧 This document is work in progress.
7+
</Alert>
8+
9+
<Alert level="info">
10+
This document uses key words such as "MUST", "SHOULD", and "MAY" as defined in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt) to indicate requirement levels.
11+
</Alert>
12+
13+
## Scrubbing data with `beforeSendSpans`
14+
15+
This callback MUST NOT allow the removal of any spans from the span tree.
16+
It receives a deep copy of all spans in the span tree and their attributes.
17+
18+
```
19+
[
20+
{
21+
'name': 'GET /',
22+
'attributes': [
23+
'http.request.method': 'GET',
24+
'http.response.status_code': 200,
25+
]
26+
},
27+
]
28+
```
29+
30+
Users MAY mutate any exposed properties to perform sanitation on sensitive data or PII.
31+
The return value of `beforeSendSpans` MUST be merged with the original span tree prior to emission.

0 commit comments

Comments
 (0)