Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,44 @@
`logsEnabled` argument. Pass `false` to keep Sentry Logs disabled.
- Disable tracing for HTTP `OPTIONS` requests by default. Set `traceOptionsRequests` to `true` to
preserve the previous behavior ([#6254](https://github.com/getsentry/sentry-java/pull/6254))
- Incoming HTTP server transactions that finish with status 301-303, 305-399, or 401-404 are no
longer sent to Sentry by default. This includes matched endpoints that intentionally return one
of these statuses. Outgoing HTTP requests with matching statuses are unaffected.

Restore the previous behavior and trace every incoming HTTP status with an empty configuration:

Java:

```java
import java.util.Collections;

options.setTraceIgnoreStatusCodes(Collections.emptyList());
```

`sentry.properties`:

```properties
trace-ignore-status-codes=
```

Spring Boot `application.properties`:

```properties
sentry.trace-ignore-status-codes=
```

Spring Boot `application.yml`:

```yaml
sentry:
trace-ignore-status-codes: []
```

The final response status is only known after sampling and request handling. The transaction may
already have propagated a sampled trace to downstream services, which can still report their
segments. Local child spans are discarded with the ignored transaction. Continuous profile
chunks are reported independently. External OTLP export does not pass through `SentryClient` and
is not filtered by this option ([#6567](https://github.com/getsentry/sentry-java/pull/6567))
- Remove the Apache HttpClient transport and stop publishing `sentry-apache-http-client-5` ([#6214](https://github.com/getsentry/sentry-java/pull/6214))
- Remove the deprecated `Instrumenter` enum, option, span context property, and `startChild` overloads ([#6252](https://github.com/getsentry/sentry-java/pull/6252))
- Remove deprecated OpenTelemetry integration classes and the legacy `SentrySpanStorage` ([#6243](https://github.com/getsentry/sentry-java/pull/6243))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import org.springframework.test.context.junit4.SpringRunner
properties =
[
"sentry.traces-sample-rate=1.0",
"sentry.trace-ignore-status-codes=404",
"sentry.clients.ok-http-enabled=true",
"sentry.enable-cache-tracing=true",
"sentry.enable-queue-tracing=true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class PersonIntegrationTest : IntegrationTest() {
}

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

val response = restTemplate.getForEntity(path, String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ import org.springframework.http.HttpHeaders

class PersonIntegrationTest : IntegrationTest() {

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

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

assertThat(response.statusCode.value()).isEqualTo(404)
server.assertNoEnvelope(millis = 1_000) {
it.transaction()?.request?.url?.endsWith(path) == true
}
}

@Test
fun `failed request reports errors, spans with their flags, and logs`() {
val response = restTemplate.getForEntity("/person/11", String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ import org.springframework.http.HttpHeaders

class PersonIntegrationTest : IntegrationTest() {

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

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

assertThat(response.statusCode.value()).isEqualTo(404)
server.assertNoEnvelope { it.transaction()?.request?.url?.endsWith(path) == true }
}

@Test
fun `failed request reports errors, nested spans with their flags, and logs`() {
val response = restTemplate.getForEntity("/person/11", String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PersonWebfluxIntegrationTest : WebfluxIntegrationTest() {
}

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

val response = restTemplate.getForEntity(path, String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.springframework.test.context.junit4.SpringRunner
properties =
[
"sentry.traces-sample-rate=1.0",
"sentry.trace-ignore-status-codes=404",
"sentry.enable-cache-tracing=true",
"sentry.logs.enabled=true",
"sentry.reactive.thread-local-accessor-enabled=true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,20 @@ class SentryAutoConfigurationTest {
}
}

@Test
fun `ignored server HTTP status codes use the spec defaults`() {
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj").run {
val ranges = it.getBean(SentryProperties::class.java).traceIgnoreStatusCodes!!
assertThat(ranges).hasSize(3)
listOf(301, 303, 305, 399, 401, 404).forEach { statusCode ->
assertThat(ranges.any { it.isInRange(statusCode) }).isTrue()
}
listOf(300, 304, 400, 405).forEach { statusCode ->
assertThat(ranges.any { it.isInRange(statusCode) }).isFalse()
}
}
}

@Test
fun `YAML list binds integer ignored server HTTP status codes`() {
dsnEnabledRunner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import org.springframework.test.context.junit4.SpringRunner
properties =
[
"sentry.traces-sample-rate=1.0",
"sentry.trace-ignore-status-codes=404",
"sentry.clients.ok-http-enabled=true",
"sentry.enable-cache-tracing=true",
"sentry.enable-queue-tracing=true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class PersonIntegrationTest : IntegrationTest() {
}

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

val response = restTemplate.getForEntity(path, String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ import org.springframework.http.HttpHeaders

class PersonIntegrationTest : IntegrationTest() {

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

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

assertThat(response.statusCode.value()).isEqualTo(404)
server.assertNoEnvelope(millis = 1_000) {
it.transaction()?.request?.url?.endsWith(path) == true
}
}

@Test
fun `failed request reports errors, spans with their flags, and logs`() {
val response = restTemplate.getForEntity("/person/11", String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ import org.springframework.http.HttpHeaders

class PersonIntegrationTest : IntegrationTest() {

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

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

assertThat(response.statusCode.value()).isEqualTo(404)
server.assertNoEnvelope { it.transaction()?.request?.url?.endsWith(path) == true }
}

@Test
fun `failed request reports errors, nested spans with their flags, and logs`() {
val response = restTemplate.getForEntity("/person/11", String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PersonWebfluxIntegrationTest : WebfluxIntegrationTest() {
}

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

val response = restTemplate.getForEntity(path, String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.springframework.test.context.junit4.SpringRunner
properties =
[
"sentry.traces-sample-rate=1.0",
"sentry.trace-ignore-status-codes=404",
"sentry.enable-cache-tracing=true",
"sentry.logs.enabled=true",
"sentry.reactive.thread-local-accessor-enabled=true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,20 @@ class SentryAutoConfigurationTest {
}
}

@Test
fun `ignored server HTTP status codes use the spec defaults`() {
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj").run {
val ranges = it.getBean(SentryProperties::class.java).traceIgnoreStatusCodes!!
assertThat(ranges).hasSize(3)
listOf(301, 303, 305, 399, 401, 404).forEach { statusCode ->
assertThat(ranges.any { it.isInRange(statusCode) }).isTrue()
}
listOf(300, 304, 400, 405).forEach { statusCode ->
assertThat(ranges.any { it.isInRange(statusCode) }).isFalse()
}
}
}

@Test
fun `YAML list binds integer ignored server HTTP status codes`() {
dsnEnabledRunner
Expand Down
24 changes: 19 additions & 5 deletions sentry-spring-boot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,27 @@ For more information check out [Sentry Spring Boot documentation](https://docs.s

## Ignoring server transactions by HTTP status

Set `sentry.trace-ignore-status-codes` to a comma-separated list of individual
status codes and inclusive ranges:
Incoming server transactions that finish with HTTP status 301-303, 305-399, or 401-404 are not
sent to Sentry by default. Set `sentry.trace-ignore-status-codes` to replace the default with a
comma-separated list of individual status codes and inclusive ranges:

```properties
sentry.trace-ignore-status-codes=404,500-599
```

Matching incoming server transactions are not sent to Sentry. The filter reads the root
transaction's HTTP response status; child span statuses do not affect it. The option is disabled
when it is unset or empty.
Use an empty value to trace every incoming HTTP status:

```properties
sentry.trace-ignore-status-codes=
```

For YAML configuration, use an empty list:

```yaml
sentry:
trace-ignore-status-codes: []
```

The filter reads the root transaction's HTTP response status; child span statuses do not affect it.
Filtering happens after the response status is known, so the request may already have propagated a
sampled trace, and local child spans are discarded with the transaction.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import org.springframework.test.context.junit4.SpringRunner
properties =
[
"sentry.traces-sample-rate=1.0",
"sentry.trace-ignore-status-codes=404",
"sentry.clients.ok-http-enabled=true",
"sentry.enable-cache-tracing=true",
"sentry.enable-queue-tracing=true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class PersonIntegrationTest : IntegrationTest() {
}

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

val response = restTemplate.getForEntity(path, String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ import org.springframework.http.HttpHeaders

class PersonIntegrationTest : IntegrationTest() {

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

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

assertThat(response.statusCode.value()).isEqualTo(404)
server.assertNoEnvelope(millis = 1_000) {
it.transaction()?.request?.url?.endsWith(path) == true
}
}

@Test
fun `failed request reports errors, spans with their flags, and logs`() {
val response = restTemplate.getForEntity("/person/11", String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ import org.springframework.http.HttpHeaders

class PersonIntegrationTest : IntegrationTest() {

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

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

assertThat(response.statusCode.value()).isEqualTo(404)
server.assertNoEnvelope { it.transaction()?.request?.url?.endsWith(path) == true }
}

@Test
fun `failed request reports errors, nested spans with their flags, and logs`() {
val response = restTemplate.getForEntity("/person/11", String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PersonWebfluxIntegrationTest : WebfluxIntegrationTest() {
}

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

val response = restTemplate.getForEntity(path, String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.springframework.test.context.junit4.SpringRunner
properties =
[
"sentry.traces-sample-rate=1.0",
"sentry.trace-ignore-status-codes=404",
"sentry.logs.enabled=true",
"sentry.profile-session-sample-rate=1.0",
"sentry.profile-lifecycle=TRACE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,20 @@ class SentryAutoConfigurationTest {
}
}

@Test
fun `ignored server HTTP status codes use the spec defaults`() {
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj").run {
val ranges = it.getBean(SentryProperties::class.java).traceIgnoreStatusCodes!!
assertThat(ranges).hasSize(3)
listOf(301, 303, 305, 399, 401, 404).forEach { statusCode ->
assertThat(ranges.any { it.isInRange(statusCode) }).isTrue()
}
listOf(300, 304, 400, 405).forEach { statusCode ->
assertThat(ranges.any { it.isInRange(statusCode) }).isFalse()
}
}
}

@Test
fun `YAML list binds integer ignored server HTTP status codes`() {
dsnEnabledRunner
Expand Down
Loading
Loading