Skip to content

Commit 34a46af

Browse files
authored
feat(develop): document traceIgnoreStatusCodes (#15026)
1 parent 7062170 commit 34a46af

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

develop-docs/sdk/telemetry/traces/index.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,34 @@ Header Format:
128128

129129
The full spec is available in the [W3C Trace Context](https://www.w3.org/TR/trace-context/) specification.
130130

131+
### `traceIgnoreStatusCodes`
132+
133+
This SHOULD be a collection of integers, denoting HTTP status codes.
134+
If suitable for the platform, the collection MAY also admit pairs of integers, denoting inclusive HTTP status code ranges.
135+
136+
The option applies exclusively to incoming requests, and therefore MUST only be implemented in server SDKs.
137+
138+
The SDK MUST honor this option by inspecting the [`http.response.status_code`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/http/#:~:text=1437-,http.response.status_code,-int) attribute on each transaction/root span before it's finished.
139+
If the value of this attribute matches one of the status codes in `traceIgnoreStatusCodes`, the SDK MUST set the transaction's [sampling decision](https://develop.sentry.dev/sdk/telemetry/traces/#sampling) to `not sampled`.
140+
141+
Note that a prerequisite to implement this option is that every HTTP server integration MUST record the [`http.response.status_code`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/http/#:~:text=1437-,http.response.status_code,-int) attribute as defined in the OTEL spec.
142+
143+
The SDK MUST emit a debug log denoting why the transaction was dropped.
144+
If the SDK implements client reports, it MUST record the dropped transaction with the `event_processor` discard reason.
145+
146+
This option MUST default to an empty collection if it's introduced in a release with a minor SemVer bump.
147+
SDKs SHOULD set the default for this option to the following value (or equivalent if the implementation doesn't admit pairs of integers)
148+
```
149+
[[301, 303], [305, 399], [401, 404]]
150+
```
151+
at the earliest release with a major SemVer bump following its introduction.
152+
153+
The rationale for this option and default is to not consume a user's span quota to trace requests that are useless for debugging purposes (and can often be triggered by scanning bots).
154+
155+
Examples:
156+
`[403, 404]`: don't sample transactions corresponding to requests with status code 403 or 404
157+
`[[300, 399], [401, 404]]`: don't sample transactions corresponding to requests with status codes between 300 and 399 (inclusive) or between 401 and 404 (inclusive)
158+
131159
## `Event` Changes
132160

133161
As of writing, transactions are implemented as an extension of the `Event`

0 commit comments

Comments
 (0)