Skip to content

runBlocking coroutines with sentry-opentelemetry-agentless-spring throws error on e.g. webclient calls #4806

@luben93

Description

@luben93

Integration

sentry-opentelemetry-agentless-spring

Java Version

21

Version

8.23.0 - 8.20.0?

Steps to Reproduce

contrived example app that is affected:
https://github.com/luben93/sentry-coroutine-example

the actual code where this was discovered contains alot more reasons for using runBlocking:

Expected Result

i expect that a coroutine that is created with runBlocking gets the same context propagation and is able to access the sentry options that was configured on boot, and the webClient call in the example is returning the actual data

Actual Result

sentry throws an exception like below, blocking the application from processing if sentry is enabled
Error has been observed at the following site(s):
*__checkpoint ⇢ Request to GET http://localhost:8080/hello [DefaultWebClient]
Original Stack Trace:
at io.sentry.Dsn.(Dsn.java:88) ~[sentry-8.23.0.jar:8.23.0]
at io.sentry.SentryOptions.lambda$new$0(SentryOptions.java:96) ~[sentry-8.23.0.jar:8.23.0]
at io.sentry.util.LazyEvaluator.getValue(LazyEvaluator.java:39) ~[sentry-8.23.0.jar:8.23.0]
at io.sentry.SentryOptions.retrieveParsedDsn(SentryOptions.java:682) ~[sentry-8.23.0.jar:8.23.0]
at io.sentry.Baggage.setValuesFromTransaction(Baggage.java:497) ~[sentry-8.23.0.jar:8.23.0]
at io.sentry.opentelemetry.OtelSpanWrapper.updateBaggageValues(OtelSpanWrapper.java:232) ~[sentry-opentelemetry-core-8.23.0.jar:8.23.0]
at io.sentry.opentelemetry.OtelSpanWrapper.toBaggageHeader(OtelSpanWrapper.java:249) ~[sentry-opentelemetry-core-8.23.0.jar:8.23.0]
at io.sentry.util.TracingUtils.trace(TracingUtils.java:65) ~[sentry-8.23.0.jar:8.23.0]
at io.sentry.util.TracingUtils.traceIfAllowed(TracingUtils.java:51) ~[sentry-8.23.0.jar:8.23.0]
at io.sentry.opentelemetry.OtelSentryPropagator.inject(OtelSentryPropagator.java:81) ~[sentry-opentelemetry-core-8.23.0.jar:8.23.0]
at io.opentelemetry.instrumentation.spring.webflux.v5_3.internal.WebClientTracingFilter$MonoWebClientTrace.subscribe(WebClientTracingFilter.java:63) ~[opentelemetry-spring-webflux-5.3-2.17.0-alpha.jar:2.17.0-alpha]
at reactor.core.publisher.MonoContextWriteRestoringThreadLocals.subscribe(MonoContextWriteRestoringThreadLocals.java:44) ~[reactor-core-3.7.11.jar:3.7.11]
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76) ~[reactor-core-3.7.11.jar:3.7.11]
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53) ~[reactor-core-3.7.11.jar:3.7.11]
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76) ~[reactor-core-3.7.11.jar:3.7.11]
at reactor.core.publisher.MonoContextWriteRestoringThreadLocals.subscribe(MonoContextWriteRestoringThreadLocals.java:44) ~[reactor-core-3.7.11.jar:3.7.11]
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76) ~[reactor-core-3.7.11.jar:3.7.11]
at reactor.core.publisher.MonoDeferContextual.subscribe(MonoDeferContextual.java:55) ~[reactor-core-3.7.11.jar:3.7.11]
at reactor.core.publisher.Mono.subscribe(Mono.java:4576) ~[reactor-core-3.7.11.jar:3.7.11]
at kotlinx.coroutines.reactive.AwaitKt.awaitOne(Await.kt:186) ~[kotlinx-coroutines-reactive-1.8.1.jar:na]
at kotlinx.coroutines.reactive.AwaitKt.awaitOne$default(Await.kt:179) ~[kotlinx-coroutines-reactive-1.8.1.jar:na]
at kotlinx.coroutines.reactive.AwaitKt.awaitSingle(Await.kt:77) ~[kotlinx-coroutines-reactive-1.8.1.jar:na]
at com.example.demo.HelloController$hello$1.invokeSuspend(DemoApplication.kt:35) ~[classes/:na]

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions