Pedro Sousa
03/30/2023, 8:50 AM@RestController
class TestController(val tracer: Tracer) {
private val logger: Logger = LoggerFactory.getLogger(this::class.java)
@GetMapping("/test")
suspend fun test() {
<http://logger.info|logger.info>("before: ${tracer.currentTraceContext().context()?.traceId()}")
delay(50)
<http://logger.info|logger.info>("after: ${tracer.currentTraceContext().context()?.traceId()}")
}
}
The second log statement reports a null value for the traceId, because the Kotlin delay
function caused a thread switch and the trace informations is lost,
Can anyone help here? Why is this happening? Is it by design? Is there something I can do to guarantee that the traceId is always present?Riccardo Lippolis
03/30/2023, 9:09 AM