Skip to content

Commit 0e12b0b

Browse files
adinauerclaude
andauthored
feat(tracing): [Ignore HTTP Status 4] Use spec status defaults (#6567)
* feat(tracing): [Ignore HTTP Status 4] Ignore incoming 404s by default Stop sending incoming server transactions that finish with HTTP 404 unless users replace or clear the ignored status configuration. Document the opt-out and cover native Spring and OpenTelemetry paths across supported Spring Boot generations. Fixes #4736 * changelog * feat(tracing): Align ignored status defaults with spec Default traceIgnoreStatusCodes to 301-303, 305-399, and 401-404 instead of only 404. Update documentation and boundary coverage so excluded gaps remain captured. Refs #4736 Co-Authored-By: Claude <noreply@anthropic.com> * fix(core): Make trace ignore statuses thread-safe Store traceIgnoreStatusCodes in a copy-on-write list so callers can mutate the exposed configuration while transactions iterate it. Mark the replaceable reference volatile so setter updates are visible across threads. Refs #4736 Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
2 parents fbf86b6 + 10243cf commit 0e12b0b

26 files changed

Lines changed: 275 additions & 47 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,44 @@
5252
`logsEnabled` argument. Pass `false` to keep Sentry Logs disabled.
5353
- Disable tracing for HTTP `OPTIONS` requests by default. Set `traceOptionsRequests` to `true` to
5454
preserve the previous behavior ([#6254](https://github.com/getsentry/sentry-java/pull/6254))
55+
- Incoming HTTP server transactions that finish with status 301-303, 305-399, or 401-404 are no
56+
longer sent to Sentry by default. This includes matched endpoints that intentionally return one
57+
of these statuses. Outgoing HTTP requests with matching statuses are unaffected.
58+
59+
Restore the previous behavior and trace every incoming HTTP status with an empty configuration:
60+
61+
Java:
62+
63+
```java
64+
import java.util.Collections;
65+
66+
options.setTraceIgnoreStatusCodes(Collections.emptyList());
67+
```
68+
69+
`sentry.properties`:
70+
71+
```properties
72+
trace-ignore-status-codes=
73+
```
74+
75+
Spring Boot `application.properties`:
76+
77+
```properties
78+
sentry.trace-ignore-status-codes=
79+
```
80+
81+
Spring Boot `application.yml`:
82+
83+
```yaml
84+
sentry:
85+
trace-ignore-status-codes: []
86+
```
87+
88+
The final response status is only known after sampling and request handling. The transaction may
89+
already have propagated a sampled trace to downstream services, which can still report their
90+
segments. Local child spans are discarded with the ignored transaction. Continuous profile
91+
chunks are reported independently. External OTLP export does not pass through `SentryClient` and
92+
is not filtered by this option ([#6567](https://github.com/getsentry/sentry-java/pull/6567))
5593
- Remove the Apache HttpClient transport and stop publishing `sentry-apache-http-client-5` ([#6214](https://github.com/getsentry/sentry-java/pull/6214))
5694
- Remove the deprecated `Instrumenter` enum, option, span context property, and `startChild` overloads ([#6252](https://github.com/getsentry/sentry-java/pull/6252))
5795
- Remove deprecated OpenTelemetry integration classes and the legacy `SentrySpanStorage` ([#6243](https://github.com/getsentry/sentry-java/pull/6243))

‎sentry-spring-boot-4/src/integrationTest/kotlin/io/sentry/spring/boot4/integrationtest/IntegrationTest.kt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import org.springframework.test.context.junit4.SpringRunner
2929
properties =
3030
[
3131
"sentry.traces-sample-rate=1.0",
32-
"sentry.trace-ignore-status-codes=404",
3332
"sentry.clients.ok-http-enabled=true",
3433
"sentry.enable-cache-tracing=true",
3534
"sentry.enable-queue-tracing=true",

‎sentry-spring-boot-4/src/integrationTest/kotlin/io/sentry/spring/boot4/integrationtest/PersonIntegrationTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class PersonIntegrationTest : IntegrationTest() {
103103
}
104104

105105
@Test
106-
fun `configured not found response does not send a transaction`() {
106+
fun `default not found response does not send a transaction`() {
107107
val path = "/missing-ignored-status"
108108

109109
val response = restTemplate.getForEntity(path, String::class.java)

‎sentry-spring-boot-4/src/integrationTestOtelAgent/kotlin/io/sentry/spring/boot4/otelagentintegrationtest/PersonIntegrationTest.kt‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ import org.springframework.http.HttpHeaders
2020

2121
class PersonIntegrationTest : IntegrationTest() {
2222

23+
@Test
24+
fun `default not found response does not send a transaction`() {
25+
val path = "/missing-default-ignored-status"
26+
27+
val response = restTemplate.getForEntity(path, String::class.java)
28+
29+
assertThat(response.statusCode.value()).isEqualTo(404)
30+
server.assertNoEnvelope(millis = 1_000) {
31+
it.transaction()?.request?.url?.endsWith(path) == true
32+
}
33+
}
34+
2335
@Test
2436
fun `failed request reports errors, spans with their flags, and logs`() {
2537
val response = restTemplate.getForEntity("/person/11", String::class.java)

‎sentry-spring-boot-4/src/integrationTestOtelNoAgent/kotlin/io/sentry/spring/boot4/otelnoagentintegrationtest/PersonIntegrationTest.kt‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ import org.springframework.http.HttpHeaders
2121

2222
class PersonIntegrationTest : IntegrationTest() {
2323

24+
@Test
25+
fun `default not found response does not send a transaction`() {
26+
val path = "/missing-default-ignored-status"
27+
28+
val response = restTemplate.getForEntity(path, String::class.java)
29+
30+
assertThat(response.statusCode.value()).isEqualTo(404)
31+
server.assertNoEnvelope { it.transaction()?.request?.url?.endsWith(path) == true }
32+
}
33+
2434
@Test
2535
fun `failed request reports errors, nested spans with their flags, and logs`() {
2636
val response = restTemplate.getForEntity("/person/11", String::class.java)

‎sentry-spring-boot-4/src/integrationTestWebflux/kotlin/io/sentry/spring/boot4/webfluxintegrationtest/PersonWebfluxIntegrationTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class PersonWebfluxIntegrationTest : WebfluxIntegrationTest() {
6767
}
6868

6969
@Test
70-
fun `configured not found response does not send a transaction`() {
70+
fun `default not found response does not send a transaction`() {
7171
val path = "/missing-ignored-status"
7272

7373
val response = restTemplate.getForEntity(path, String::class.java)

‎sentry-spring-boot-4/src/integrationTestWebflux/kotlin/io/sentry/spring/boot4/webfluxintegrationtest/WebfluxIntegrationTest.kt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import org.springframework.test.context.junit4.SpringRunner
2626
properties =
2727
[
2828
"sentry.traces-sample-rate=1.0",
29-
"sentry.trace-ignore-status-codes=404",
3029
"sentry.enable-cache-tracing=true",
3130
"sentry.logs.enabled=true",
3231
"sentry.reactive.thread-local-accessor-enabled=true",

‎sentry-spring-boot-4/src/test/kotlin/io/sentry/spring/boot4/SentryAutoConfigurationTest.kt‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,20 @@ class SentryAutoConfigurationTest {
342342
}
343343
}
344344

345+
@Test
346+
fun `ignored server HTTP status codes use the spec defaults`() {
347+
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj").run {
348+
val ranges = it.getBean(SentryProperties::class.java).traceIgnoreStatusCodes!!
349+
assertThat(ranges).hasSize(3)
350+
listOf(301, 303, 305, 399, 401, 404).forEach { statusCode ->
351+
assertThat(ranges.any { it.isInRange(statusCode) }).isTrue()
352+
}
353+
listOf(300, 304, 400, 405).forEach { statusCode ->
354+
assertThat(ranges.any { it.isInRange(statusCode) }).isFalse()
355+
}
356+
}
357+
}
358+
345359
@Test
346360
fun `YAML list binds integer ignored server HTTP status codes`() {
347361
dsnEnabledRunner

‎sentry-spring-boot-jakarta/src/integrationTest/kotlin/io/sentry/spring/boot/jakarta/integrationtest/IntegrationTest.kt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import org.springframework.test.context.junit4.SpringRunner
2929
properties =
3030
[
3131
"sentry.traces-sample-rate=1.0",
32-
"sentry.trace-ignore-status-codes=404",
3332
"sentry.clients.ok-http-enabled=true",
3433
"sentry.enable-cache-tracing=true",
3534
"sentry.enable-queue-tracing=true",

‎sentry-spring-boot-jakarta/src/integrationTest/kotlin/io/sentry/spring/boot/jakarta/integrationtest/PersonIntegrationTest.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class PersonIntegrationTest : IntegrationTest() {
103103
}
104104

105105
@Test
106-
fun `configured not found response does not send a transaction`() {
106+
fun `default not found response does not send a transaction`() {
107107
val path = "/missing-ignored-status"
108108

109109
val response = restTemplate.getForEntity(path, String::class.java)

0 commit comments

Comments
 (0)