Closed willarmiros closed 3 years ago
For now, customers can workaround this issue by manually adding the trace ID injector in a static block with their preferred prefix, e.g.:
static {
AWSXRay.getGlobalRecorder().addSegmentListener(new SLF4JSegmentListener("my trace ID prefix"));
}
Note that this workaround will not respect the traceIdInjectionEnabled/prefix setting in your X-Ray Agent config file.
Hi @willarmiros ,
It is working after adding static block in application.java file of Spring Boot. But on another hand, it is disable/not picked up the xray-agent.json file for agent configuration.
like traceIdInjectionPrefix in xray-agent.json will be replace with logback.xml's console log pattern.
Do you have any alternative solution for that?
Thanks, Chintan Kadia
@kadiachintan thanks for the callout, I've updated the sample code to include the possibility of adding a custom prefix. Using this workaround will indeed not respect the xray-agent.json
file since the trace ID injection is being configured in application code, rather than agent code, until this bug is fixed.
@willarmiros , apart from custom prefix , what if we want to use other properties of xray-agent.json.? As I pushed the static code ,all the xray-agent.json configuration will be ignored and all the spring boot application will refer to same default service name.
Any solution to explicitly provide xray-agent.json in spring boot.
@kadiachintan This should be addressed in #77. As a workaround for right now you can set the system prop -Dcom.amazonaws.xray.configFile= /BOOT-INF/classes/xray-agent.json
on the command line when running your app.
Fixed in 2.9.0
Enabling Trace ID injection via the agent is not currently possible when using Spring Boot. The agent relies on the
aws-xray-recorder-sdk-slf4j
dependency to be available on the classpath when the agent starts up so it can add the trace ID injector. When the Spring Boot app is packaged withmvn clean package
, Spring Boot does packages dependencies weirdly in a way that's not visible to the system class loader when the Agent is starting up.I think the solution here is to lazy load the trace ID injector, after the spring boot app has started up, once the dependency is discoverable.