Comment From: mhalbritter
In a servlet application, the logs look like this:
{"@timestamp":"2024-08-29T06:48:50.886628003Z","log.level":"INFO","process.pid":66723,"process.thread.name":"http-nio-9000-exec-1","service.name":"tracing-service-1","log.logger":"com.example.tracing_service_1.MyController","message":"index()","traceId":"66d019d24f3c84880516a1c3aa2368c5","spanId":"0516a1c3aa2368c5","ecs.version":"8.11"}
This is using Brave as a tracer. The traceId and the spanId are in the MDC and are automatically included in the log message.
Comment From: mhalbritter
In a webflux application, the traceId and spanId is missing from the log message:
{"@timestamp":"2024-08-29T06:58:19.344283535Z","log.level":"INFO","process.pid":72293,"process.thread.name":"reactor-http-epoll-3","service.name":"tracing-service-1","log.logger":"com.example.tracing_service_1.MyController","message":"index()","ecs.version":"8.11"}
When switching on the automatic context propagation with
spring.reactor.context-propagation=auto
then the trace id and span id appear (because they are now in the MDC):
{"@timestamp":"2024-08-29T07:01:42.393234306Z","log.level":"INFO","process.pid":74038,"process.thread.name":"reactor-http-epoll-3","service.name":"tracing-service-1","log.logger":"com.example.tracing_service_1.MyController","message":"index()","traceId":"66d01cd6899c9f52af89cde7e016d4f6","spanId":"af89cde7e016d4f6","ecs.version":"8.11"}
Comment From: mhalbritter
Same behavior with Otel instead of Brave.
Comment From: philwebb
Seems like it generally works. I wonder if we should add a note in the docs about spring.reactor.context-propagation=auto?
Comment From: philwebb
There is a note already at https://docs.spring.io/spring-boot/reference/actuator/observability.html. We can extract a small section and add a TIP next to the correlation IDs section.