Filtering
🚧 This document is work in progress.
This document uses key words such as "MUST", "SHOULD", and "MAY" as defined in RFC 2119 to indicate requirement levels.
The SDK MUST implement a mechanism for users to filter out spans. The result MUST be binary (true
or false
). Any APIs exposed to the user to filter spans MUST adhere to the following design principles:
- The APIs are optimized for trace completeness
- The APIs are optimized for conclusive sampling decisions
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.
type IgnoreSpanPattern = string | RegExp | GlobPattern;
type IgnoreSpanFilter = {
name: IgnoreSpanPattern;
op?: IgnoreSpanPattern;
} | {
name?: IgnoreSpanPattern;
op: IgnoreSpanPattern;
}
type IgnoreSpans = Array<IgnoreSpanPattern | IgnoreSpanFilter>
(Note: GlobPattern
is used as an illustrative type. It is not a valid TypeScript type.)
Example:
Sentry.init({
ignoreSpans: [
'GET /about',
'events.signal *',
/api\/\d+/,
{
op: 'fs.read',
},
{
name: /healthz?/,
op: 'http.client',
}
]
})
(Note: The glob pattern serves an illustrative purpose. It is not supported in JavaScript.)
The ignoreSpans
patterns MUST be applied to all spans, including the root or segment span.
- If a pattern matches the root span, the span and all its children MUST be ignored.
- 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.
The integrations
option MAY perform in similar fashion as the ignoreSpans
option, or make explicit opt-out possible via a boolean flag.
Sentry.init({
integrations: [
fsIntegration: {
ignoreSpans: [
'fs.read',
],
readSpans: true,
writeSpans: false,
}
]
})
If both options mentioned above are not feasible to be implemented in certain SDKs, other approaches MUST be explored that have the same outcome.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").