aws / aws-xray-java-agent

The official AWS X-Ray Auto Instrumentation Agent for Java.
Apache License 2.0
42 stars 18 forks source link

Fixed trace ID injection with spring boot #75

Closed willarmiros closed 3 years ago

willarmiros commented 3 years ago

Issue #, if available:

74

Description of changes: Refactored the trace ID injection logic to try to enable it once during premain, and again while handling the first instrumented request. This allows us to check for the trace ID injection classes (Log4JSegmentListener and SLF4JSegmentListener) using the customer app's class loader, in case they're using a custom one, as is the case for Spring Boot apps.

In the future, as I noted in my TODO task, we should bundle those two classes in the Agent JAR and enable trace ID injection by default so long as the corresponding logging library (Log4J or SLF4J) is available on the customer's class loader. But this was a little too much work for now.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

willarmiros commented 3 years ago

Opened #76 to track smoke test