question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sleuth does not work in Coroutines context

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
marcingrzejszczakcommented, Jun 2, 2022

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.

0reactions
tmdgusyacommented, Jun 2, 2022

okey thank you i’ll upgrade version!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found