Skip to content

Commit 890aba7

Browse files
committed
switch to attribute matching instead of op
1 parent 35eb5f2 commit 890aba7

File tree

1 file changed

+41
-15
lines changed

1 file changed

+41
-15
lines changed

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

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,48 +19,74 @@ 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 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.
22+
The `ignoreSpans` option MUST accept a string, RegExp or glob pattern (whichever of the two the platform supports). These values MUST be matched against the span name.
23+
24+
Furthermore, `ignoreSpans` SHOULD accept an Object with patterns matching the span name, or span attributes (see type definitions below).
2325

2426
```ts
25-
type IgnoreSpanPattern = string | RegExp | GlobPattern;
27+
type IgnoreSpanNamePattern = string | RegExp | GlobPattern;
28+
29+
// all allowed values for span attributes (unlikely but could differ by platform)
30+
type AttributeValueTypes = string | boolean | number | Array<string> | Array<boolean> | Array<number>;
31+
type EnhancedAttributeValueTypes = AttributeValueTypes | RegExp | GlobPattern;
2632

2733
type IgnoreSpanFilter = {
28-
name: IgnoreSpanPattern;
29-
op?: IgnoreSpanPattern;
34+
name: IgnoreSpanNamePattern;
35+
attributes?: Record<string, EnhancedAttributeValueTypes>;
3036
} | {
31-
name?: IgnoreSpanPattern;
32-
op: IgnoreSpanPattern;
37+
name?: IgnoreSpanNamePattern;
38+
attributes?: Record<string, EnhancedAttributeValueTypes>;
3339
}
3440

35-
type IgnoreSpans = Array<IgnoreSpanPattern | IgnoreSpanFilter>
41+
type IgnoreSpans = Array<IgnoreSpanNamePattern | IgnoreSpanFilter>
3642
```
37-
(Note: `GlobPattern` is used as an illustrative type. It is not a valid TypeScript type.)
43+
(Note: `GlobPattern` is used as an illustrative type for platforms that support matching glob patterns. It is not a valid TypeScript type.)
3844
3945
Example:
4046
4147
```js
4248
Sentry.init({
4349
ignoreSpans: [
50+
// apply on span name
4451
'GET /about',
4552
'events.signal *',
4653
/api\/\d+/,
54+
// ignore health check GET requests with 200 status code
55+
{
56+
name: /healthz?/,
57+
attributes: {
58+
'http.method': 'GET',
59+
'http.status_code': 200,
60+
}
61+
},
62+
// ignore all GET requests to /api/ with 200 status code
63+
// (i.e. span name doesn't matter)
4764
{
48-
op: 'fs.read',
65+
attributes: {
66+
'http.method': /GET \/api\/.*/,
67+
'http.status_code': 200,
68+
}
4969
},
70+
// ignore all spans with name starting with /imprint-
71+
// if glob patterns are supported
5072
{
51-
name: /healthz?/,
52-
op: 'http.client',
73+
name: '/imprint-*'
5374
}
5475
]
5576
})
5677
```
57-
(Note: The glob pattern serves an illustrative purpose. It is not supported in JavaScript.)
78+
(Note: The glob patterns used in the example serve an illustrative purpose. They are not supported in JavaScript.)
5879
5980
### Implementation Requirements
6081
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.
82+
1. The `ignoreSpans` patterns MUST be applied to all spans, including the root or segment span.
83+
- If a pattern matches the root span, the span and all its children MUST be ignored.
84+
- 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.
85+
86+
2. If SDKs accept `IgnoreSpanFilter` objects, attributes MUST be matched by value. This also applies to attributes with array values.
87+
- String attribute values are matched in the same fashion as span names: If a string is provided, the string MUST match (contains), if a `RegExp` or glob pattern is provided, the value MUST match the pattern.
88+
- Any other attribute value type MUST strictly equal the provided value.
89+
6490
6591
## Filter with `integrations`
6692

0 commit comments

Comments
 (0)