Skip to content

Commit d603095

Browse files
committed
ref(spans): Expand ignoreSpans type and implementation specification
1 parent 3a92cfb commit d603095

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

develop-docs/sdk/telemetry/spans/filtering.mdx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,48 @@ Any APIs exposed to the user to filter spans MUST adhere to the following design
1919

2020
## Filter with `ignoreSpans`
2121

22-
The `ignoreSpans` option accepts a glob pattern or string.
22+
The `ignoreSpans` option MUST accept a string, RegExp or glob pattern (whichever of the two the platform supports). Furthermore, it SHOULD accept an Object with the patterns matching at least one of or both, the span name and op.
23+
24+
```ts
25+
type IgnoreSpanPattern = string | RegExp | GlobPattern;
26+
27+
type IgnoreSpanFilter = {
28+
name: IgnoreSpanPattern;
29+
op?: IgnoreSpanPattern;
30+
} | {
31+
name?: IgnoreSpanPattern;
32+
op: IgnoreSpanPattern;
33+
}
34+
35+
type IgnoreSpans = Array<IgnoreSpanPattern | IgnoreSpanFilter>
36+
```
37+
(Note: `GlobPattern` is used as an illustrative type. It is not a valid TypeScript type.)
38+
39+
Example:
2340
2441
```js
2542
Sentry.init({
2643
ignoreSpans: [
2744
'GET /about',
2845
'events.signal *',
46+
/api\/\d+/,
47+
{
48+
op: 'fs.read',
49+
},
50+
{
51+
name: 'health',
52+
op: 'http.client',
53+
}
2954
]
3055
})
3156
```
57+
(Note: The glob pattern serves an illustrative purpose. It is not supported in JavaScript.)
58+
59+
### Implementation Requirements
60+
61+
The `ignoreSpans` patterns MUST be applied to all spans, including the root or segment span.
62+
- If a pattern matches the root span, the span and all its children MUST be ignored.
63+
- If a pattern matches a child span, the span MUST be ignored but any potential child spans MUST be attempted to be reparented to the parent span of the ignored span.
3264
3365
## Filter with `integrations`
3466

0 commit comments

Comments
 (0)