Sleuth does not work in Coroutines context
See original GitHub issueDescribe the bug traceId, spanId and exportable are not printed in Coroutines context.
Versions Spring Boot: 2.3.3.RELEASE Spring Cloud: Hoxton.SR8
Sample You can see full code by sleuth-coroutines.
@GetMapping("/hello")
suspend fun hello(): Map<String, String> {
log.info("in main context")
GlobalScope.launch {
log.info("in Coroutines context (launch)")
}
GlobalScope.async {
log.info("in Coroutines context (async)")
}.await()
return mapOf(
"msg" to "hello"
)
}
Printed log messages
2020-09-12 21:03:15.306 INFO [sleuth-coroutines,42883585174b8ae0,42883585174b8ae0,true] 22621 --- [ctor-http-nio-2] c.e.sleuthcoroutines.WebController : in main context
2020-09-12 21:03:15.312 INFO [sleuth-coroutines,,,] 22621 --- [atcher-worker-2] c.e.sleuthcoroutines.WebController : in Coroutines context (async)
2020-09-12 21:03:15.312 INFO [sleuth-coroutines,,,] 22621 --- [atcher-worker-1] c.e.sleuthcoroutines.WebController : in Coroutines context (launch)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Spring sleuth zipkin spans not nesting in Kotlin coroutine
I suspect that it's due to the thread that coroutines are executed on being different to the one in which the spring application...
Read more >Spring Cloud Sleuth customization
Sleuth does not work with parallelStream() out of the box. ... If you want to customize the way tracing context is read from...
Read more >spring-cloud/spring-cloud-sleuth - Gitter
Hello everyone. I have an integration with a 3rd-party service, which answers asynchronously, does not use tracing and the answer from the service...
Read more >Tracing a Reactive Kotlin App with Spring Cloud Sleuth
This passes the trace context in some cases, and may even cause MDC to not work (for your SLF4J logs). The performance penalty...
Read more >Spring sleuth zipkin spans not nesting in Kotlin coroutine-kotlin
Attention: This solution does works for logging purposes, but does not work ... MDC context on the worker thread whenever the coroutine is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Maybe that’s because you’re using 2.2.8? Please upgrade to the latest version.
If you check the
SimpleTracer
code you’ll see@since 3.0.4
.Kotlin code got added in 3.1.0.
okey thank you i’ll upgrade version!