Skip to content

Commit b9bad2a

Browse files
committed
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
1 parent 199172d commit b9bad2a

26 files changed

Lines changed: 226 additions & 59 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 404 are no longer sent to Sentry by
56+
default. This includes matched endpoints that intentionally return 404. Outgoing HTTP requests
57+
that receive a 404 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.
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,15 @@ class SentryAutoConfigurationTest {
341341
}
342342
}
343343

344+
@Test
345+
fun `ignored server HTTP status codes default to 404`() {
346+
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj").run {
347+
val ranges = it.getBean(SentryProperties::class.java).traceIgnoreStatusCodes
348+
assertThat(ranges).hasSize(1)
349+
assertThat(ranges!!.single().isInRange(404)).isTrue()
350+
}
351+
}
352+
344353
@Test
345354
fun `empty ignored server HTTP status codes disable the configuration`() {
346355
contextRunner

‎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)