spring-cloud-openfeign
spring-cloud-openfeign copied to clipboard
B3 span and parentId headers not propagated with spring-cloud-openfeign and brave
With sprint boot 3.1.5 in two microservices, one using FeignClient to request to the other microservice , I have this properties configuration in both microservices:
management:
tracing:
propagation:
produce: b3
consume: b3
brave:
span-joining-supported: true
logging:
pattern:
level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-},%X{parentId:-}]"
I have next library in both poms:
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-brave</artifactId>
<version>1.1.6</version>
</dependency>
I have this FeignConfiguration lets called in microservice A to get the context propagated to the microservice B:
@Configuration
public class FeignConfiguration {
@Bean
public Capability capability(final MeterRegistry registry) {
return new MicrometerCapability(registry);
}
}
I have this in order to log PARENT_ID in both microservices and is working fine:
@Configuration
public class BraveTracerConfig {
@Bean
CorrelationScopeCustomizer parentIdCorrelationScopeCustomizer() {
return builder -> builder.add(SingleCorrelationField.create(BaggageFields.PARENT_ID));
}
}
The problem is when microservice A calls microservice B, traceId is propagated but I dont see in microservice B in the logs the spanId or parentId from the feign client logs in microservice A.
First of all, I read about Spring Boot 3.x does not allow joining of spans. But with the brave configuration is supposed I can get it according to this https://github.com/spring-projects/spring-boot/pull/35165, right?
Thanks!
@jonatan-ivanov, could you take a look at this issue?
Thank you for the issue. There were a quite a few improvements in the auto-configuration in the past year:
- Please upgrade to latest Boot (3.3.1 right now)
- Please do not define a version for a dependency that is managed by Boot (Brave bridge), remove the version section and let Boot's BOM define the versions
- Setting
logging.pattern.levelis not needed anymore - You don't need to create
MicrometerCapabilityyou only need toio.github.openfeign:feign-micrometer' - I think your custom
CorrelationScopeCustomizeris not needed either though I'm not sure since I'm not 100% what you are trying to do but would you please try without it? - Brave's joint Span support was added in Boot 3.1, you need to flip a property flag to enable it as you just did (fyi: your link is broken above): Boot#35165
We have a "real-world" demo with feign (with okhttp) where this works, please feel free to take a look: https://github.com/jonatan-ivanov/teahouse. We also have a simple sample: https://github.com/micrometer-metrics/micrometer-samples/tree/main/openfeign
If after looking at these apps, this is still not working for you, could you please provide a minimal sample project to reproduce this issue so we can more easily investigate and ensure any fix is working properly for your use case?
(Fyi: your link to the Boot issue was broken, I fixed it.)
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.