Skip to content
Draft
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 404 are no longer sent to Sentry by
default. This includes matched endpoints that intentionally return 404. Outgoing HTTP requests
that receive a 404 are unaffected.

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

Java:

```java
import java.util.Collections;

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

`sentry.properties`:

```properties
ignored-server-http-status-codes-for-tracing=
```

Spring Boot `application.properties`:

```properties
sentry.ignored-server-http-status-codes-for-tracing=
```

Spring Boot `application.yml`:

```yaml
sentry:
ignored-server-http-status-codes-for-tracing: []
```

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.ignored-server-http-status-codes-for-tracing=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.ignored-server-http-status-codes-for-tracing=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 @@ -341,6 +341,15 @@ class SentryAutoConfigurationTest {
}
}

@Test
fun `ignored server HTTP status codes default to 404`() {
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj").run {
val ranges = it.getBean(SentryProperties::class.java).ignoredServerHttpStatusCodesForTracing
assertThat(ranges).hasSize(1)
assertThat(ranges!!.single().isInRange(404)).isTrue()
}
}

@Test
fun `empty ignored server HTTP status codes disable the configuration`() {
contextRunner
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.ignored-server-http-status-codes-for-tracing=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.ignored-server-http-status-codes-for-tracing=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 @@ -349,6 +349,15 @@ class SentryAutoConfigurationTest {
}
}

@Test
fun `ignored server HTTP status codes default to 404`() {
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj").run {
val ranges = it.getBean(SentryProperties::class.java).ignoredServerHttpStatusCodesForTracing
assertThat(ranges).hasSize(1)
assertThat(ranges!!.single().isInRange(404)).isTrue()
}
}

@Test
fun `empty ignored server HTTP status codes disable the configuration`() {
contextRunner
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.ignored-server-http-status-codes-for-tracing` to a comma-separated list of individual
status codes and inclusive ranges:
Incoming server transactions that finish with HTTP status 404 are not sent to Sentry by default.
Set `sentry.ignored-server-http-status-codes-for-tracing` to replace the default with a
comma-separated list of individual status codes and inclusive ranges:

```properties
sentry.ignored-server-http-status-codes-for-tracing=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.ignored-server-http-status-codes-for-tracing=
```

For YAML configuration, use an empty list:

```yaml
sentry:
ignored-server-http-status-codes-for-tracing: []
```

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.ignored-server-http-status-codes-for-tracing=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.ignored-server-http-status-codes-for-tracing=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 @@ -347,6 +347,15 @@ class SentryAutoConfigurationTest {
}
}

@Test
fun `ignored server HTTP status codes default to 404`() {
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj").run {
val ranges = it.getBean(SentryProperties::class.java).ignoredServerHttpStatusCodesForTracing
assertThat(ranges).hasSize(1)
assertThat(ranges!!.single().isInRange(404)).isTrue()
}
}

@Test
fun `empty ignored server HTTP status codes disable the configuration`() {
contextRunner
Expand Down
14 changes: 8 additions & 6 deletions sentry/src/main/java/io/sentry/SentryOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@ public class SentryOptions implements RateLimiterConfig {
*/
private @Nullable List<FilterString> ignoredTransactions = null;

private @Nullable List<HttpStatusCodeRange> ignoredServerHttpStatusCodesForTracing = null;
private @Nullable List<HttpStatusCodeRange> ignoredServerHttpStatusCodesForTracing =
new ArrayList<>(Collections.singletonList(new HttpStatusCodeRange(404)));

@ApiStatus.Experimental
private @NotNull IBackpressureMonitor backpressureMonitor = NoOpBackpressureMonitor.getInstance();
Expand Down Expand Up @@ -3151,9 +3152,10 @@ public void setIgnoredTransactions(final @Nullable List<String> ignoredTransacti

/**
* Returns the HTTP status codes and inclusive ranges for which incoming server transactions are
* not sent to Sentry. An empty list disables this filter.
* not sent to Sentry. Defaults to a single range containing 404. An empty list disables this
* filter.
*
* @return the configured HTTP status code ranges, or {@code null} if unset
* @return the configured HTTP status code ranges, or {@code null} if explicitly set to null
*/
public @Nullable List<HttpStatusCodeRange> getIgnoredServerHttpStatusCodesForTracing() {
return ignoredServerHttpStatusCodesForTracing;
Expand All @@ -3163,11 +3165,11 @@ public void setIgnoredTransactions(final @Nullable List<String> ignoredTransacti
* Sets the HTTP status codes and inclusive ranges for which incoming server transactions are not
* sent to Sentry. For example, configure {@code new HttpStatusCodeRange(404)} for one status or
* {@code new HttpStatusCodeRange(500, 599)} for an inclusive range. External configuration
* accepts comma-separated codes and ranges such as {@code 404,410,500-599}. An empty list
* disables this filter.
* accepts comma-separated codes and ranges such as {@code 404,410,500-599}. An empty list or
* {@code null} disables this filter.
*
* @param ignoredServerHttpStatusCodesForTracing the HTTP status code ranges, or {@code null} to
* leave the option unset
* disable the filter
*/
public void setIgnoredServerHttpStatusCodesForTracing(
final @Nullable List<HttpStatusCodeRange> ignoredServerHttpStatusCodesForTracing) {
Expand Down
Loading
Loading