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
ref(develop/spans): Expand ignoreSpans type and implementation specification (#14571)
Develop Docs PR that expands the specification for `ignoreSpans`:
- add object accepting `name` and `attributes`
- specify behaviour around dropping and reparenting of root vs child
spans
Copy file name to clipboardExpand all lines: develop-docs/sdk/telemetry/spans/filtering.mdx
+59-1Lines changed: 59 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,16 +19,74 @@ Any APIs exposed to the user to filter spans MUST adhere to the following design
19
19
20
20
## Filter with `ignoreSpans`
21
21
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). 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).
(Note: `GlobPattern` is used as an illustrative type for platforms that support matching glob patterns. It is not a valid TypeScript type.)
44
+
45
+
Example:
23
46
24
47
```js
25
48
Sentry.init({
26
49
ignoreSpans: [
50
+
// apply on span name
27
51
'GET /about',
28
52
'events.signal *',
53
+
/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)
64
+
{
65
+
attributes: {
66
+
'http.method': /GET \/api\/.*/,
67
+
'http.status_code':200,
68
+
}
69
+
},
70
+
// ignore all spans with name starting with /imprint-
71
+
// if glob patterns are supported
72
+
{
73
+
name:'/imprint-*'
74
+
}
29
75
]
30
76
})
31
77
```
78
+
(Note: The glob patterns used in the example serve an illustrative purpose. They are not supported in JavaScript.)
79
+
80
+
### Implementation Requirements
81
+
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.
0 commit comments