Skip to content

Commit 8ff8fd0

Browse files
adinauergetsentry-botromtsnmarkushilbloder
authored
Automatically downsample transaction when system is under load (backpressure) (#3072)
Co-authored-by: Sentry Github Bot <[email protected]> Co-authored-by: Roman Zavarnitsyn <[email protected]> Co-authored-by: Markus Hintersteiner <[email protected]> Co-authored-by: Lukas Bloder <[email protected]> Co-authored-by: Stefano <[email protected]> Co-authored-by: getsentry-bot <[email protected]> Co-authored-by: getsentry-bot <[email protected]> Co-authored-by: Richard Harrah <[email protected]>
1 parent 8d62770 commit 8ff8fd0

File tree

41 files changed

+555
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+555
-23
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
### Features
66

77
- Support multiple debug-metadata.properties ([#3024](https://github.com/getsentry/sentry-java/pull/3024))
8+
- Automatically downsample transactions when the system is under load ([#3072](https://github.com/getsentry/sentry-java/pull/3072))
9+
- You can opt into this behaviour by setting `enable-backpressure-handling=true`.
10+
- We're happy to receive feedback, e.g. [in this GitHub issue](https://github.com/getsentry/sentry-java/issues/2829)
11+
- When the system is under load we start reducing the `tracesSampleRate` automatically.
12+
- Once the system goes back to healthy, we reset the `tracesSampleRate` to its original value.
813
- (Android) Experimental: Provide more detailed cold app start information ([#3057](https://github.com/getsentry/sentry-java/pull/3057))
914
- Attaches spans for Application, ContentProvider, and Activities to app-start timings
1015
- Uses Process.startUptimeMillis to calculate app-start timings

sentry-samples/sentry-samples-spring-boot-jakarta/src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ sentry.enable-tracing=true
1313
sentry.ignored-checkins=ignored_monitor_slug_1,ignored_monitor_slug_2
1414
sentry.debug=true
1515
sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR
16+
sentry.enable-backpressure-handling=true
1617
in-app-includes="io.sentry.samples"
1718

1819
# Uncomment and set to true to enable aot compatibility

sentry-samples/sentry-samples-spring-boot-webflux-jakarta/src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ sentry.logging.minimum-event-level=info
99
sentry.logging.minimum-breadcrumb-level=debug
1010
sentry.reactive.thread-local-accessor-enabled=true
1111
sentry.enable-tracing=true
12+
sentry.enable-backpressure-handling=true

sentry-samples/sentry-samples-spring-boot-webflux/src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ sentry.enable-tracing=true
1111
spring.graphql.graphiql.enabled=true
1212
spring.graphql.websocket.path=/graphql
1313
spring.graphql.schema.printer.enabled=true
14+
sentry.enable-backpressure-handling=true

sentry-samples/sentry-samples-spring-boot/src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ sentry.enable-tracing=true
1313
sentry.ignored-checkins=ignored_monitor_slug_1,ignored_monitor_slug_2
1414
sentry.debug=true
1515
sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR
16+
sentry.enable-backpressure-handling=true
1617
in-app-includes="io.sentry.samples"
1718

1819
# Database configuration

sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ class SentryAutoConfigurationTest {
162162
"sentry.trace-propagation-targets=localhost,^(http|https)://api\\..*\$",
163163
"sentry.enabled=false",
164164
"sentry.send-modules=false",
165-
"sentry.ignored-checkins=slug1,slugB"
165+
"sentry.ignored-checkins=slug1,slugB",
166+
"sentry.enable-backpressure-handling=true"
166167
).run {
167168
val options = it.getBean(SentryProperties::class.java)
168169
assertThat(options.readTimeoutMillis).isEqualTo(10)
@@ -194,6 +195,7 @@ class SentryAutoConfigurationTest {
194195
assertThat(options.isEnabled).isEqualTo(false)
195196
assertThat(options.isSendModules).isEqualTo(false)
196197
assertThat(options.ignoredCheckIns).containsOnly("slug1", "slugB")
198+
assertThat(options.isEnableBackpressureHandling).isEqualTo(true)
197199
}
198200
}
199201

sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/it/SentrySpringIntegrationTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ class SentrySpringIntegrationTest {
210210

211211
@SpringBootApplication
212212
open class App {
213-
private val transport = mock<ITransport>()
213+
private val transport = mock<ITransport>().also {
214+
whenever(it.isHealthy).thenReturn(true)
215+
}
214216

215217
@Bean
216218
open fun mockTransportFactory(): ITransportFactory {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ class SentryAutoConfigurationTest {
162162
"sentry.trace-propagation-targets=localhost,^(http|https)://api\\..*\$",
163163
"sentry.enabled=false",
164164
"sentry.send-modules=false",
165-
"sentry.ignored-checkins=slug1,slugB"
165+
"sentry.ignored-checkins=slug1,slugB",
166+
"sentry.enable-backpressure-handling=true"
166167
).run {
167168
val options = it.getBean(SentryProperties::class.java)
168169
assertThat(options.readTimeoutMillis).isEqualTo(10)
@@ -194,6 +195,7 @@ class SentryAutoConfigurationTest {
194195
assertThat(options.isEnabled).isEqualTo(false)
195196
assertThat(options.isSendModules).isEqualTo(false)
196197
assertThat(options.ignoredCheckIns).containsOnly("slug1", "slugB")
198+
assertThat(options.isEnableBackpressureHandling).isEqualTo(true)
197199
}
198200
}
199201

sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/it/SentrySpringIntegrationTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ class SentrySpringIntegrationTest {
210210

211211
@SpringBootApplication
212212
open class App {
213-
private val transport = mock<ITransport>()
213+
private val transport = mock<ITransport>().also {
214+
whenever(it.isHealthy).thenReturn(true)
215+
}
214216

215217
@Bean
216218
open fun mockTransportFactory(): ITransportFactory {

sentry-spring-jakarta/src/test/kotlin/io/sentry/spring/jakarta/EnableSentryTest.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import io.sentry.ITransportFactory
66
import io.sentry.Integration
77
import io.sentry.Sentry
88
import io.sentry.SentryOptions
9+
import io.sentry.transport.ITransport
910
import org.assertj.core.api.Assertions.assertThat
11+
import org.mockito.kotlin.any
1012
import org.mockito.kotlin.mock
13+
import org.mockito.kotlin.whenever
1114
import org.springframework.boot.context.annotation.UserConfigurations
1215
import org.springframework.boot.test.context.runner.ApplicationContextRunner
1316
import org.springframework.context.annotation.Bean
@@ -185,7 +188,9 @@ class EnableSentryTest {
185188
class AppConfigWithCustomTransportFactory {
186189

187190
@Bean
188-
fun transport() = mock<ITransportFactory>()
191+
fun transport() = mock<ITransportFactory>().also {
192+
whenever(it.create(any(), any())).thenReturn(mock<ITransport>())
193+
}
189194
}
190195

191196
@EnableSentry(dsn = "http://key@localhost/proj")

0 commit comments

Comments
 (0)