I'm using micrometer tracing with Brave as my vendor. I observed that micrometer is not honoring parentSpanId in any of the 3 below scenarios:
- When I create a
nextSpanwithin the application, I expect the previousspanIdto be present in MDC asparentSpanId. - When my service is called by another service and the request Header contains
X-B3-SpanId, I expect this ID to be available in MDC asparentSpanId.
But neither of these are happening.
Following is my application.properties file:
server.port=8085
spring.application.name=exampleApp
logging.pattern.console=%d{yyyy-MM-dd }, [[[%mdc]]] [%thread] %-5level %logger{36} - %msg%n
management.tracing.sampling.probability=0.0
management.tracing.propagation.type=B3_MULTI
logging.level.root=info
There's no customization on top of this and I am totally relying on the Spring Auto configuration of micrometer..
I tried adding the following property after reading the documentation here which read
List of fields that should be correlated with the logging context. That means that these fields would end up as key-value pairs in e.g. MDC.
management.tracing.baggage.correlation.fields=parentSpanId,X-B3-ParentSpanId,parentId
But I see no changes in MDC. How do I get this working?
Micrometer is not honoring the property. This seems like bug in Micrometer. I have reported the same in github
However, I figured this could be configured by creating a spring bean.
I have also customized the
parentIdto be added asparentSpanIdin MDC.This bean will be picked up by
BraveAutoConfiguration#mdcCorrelationScopeDecoratorBuilderduring autoconfiguration and customized accordingly.