Fully qualified, configurable Trace ID Injection - #135
Conversation
|
Can you discuss impact to any integrations (e.g. Log searches) or other backwards compatibility or upgrade issues customers may face? |
|
|
||
| /** | ||
| * beforeEndSubsegment is invoked just before a subsegment is ended by the recorder. | ||
| * The subsegment can be manipulated, e.g. with putAnnotation. |
There was a problem hiding this comment.
putAnnotation doesn't seem to be a good example because even with final you can still call subsegment.putAnnotation. BTW I'm confused by "The subsegment cannot be manipulated". The subsegment itself is surely mutable. The argument is a referrence of the subsegment. The method can never replace the original subsegment, so what is the point to allow manipulating the referrence? (ref https://stackoverflow.com/questions/1249917/final-variable-manipulation-in-java)
There was a problem hiding this comment.
This is a fair callout. The (sub)segment can't be modified in afterEndSegment because it is invoked after the segment is emitted to the daemon, and attempting to modify it would raise an AlreadyEmittedException. I'll update the docs to clarify this.
I added the final keyword to indicate its immutability, but you're right that making a parameter final does not make it immutable. I'll remove the final to avoid confusion.
Description of changes
TraceID@EntityID, for example:AWSXRay.currentFormattedId()APINote that this change will affect customers who are currently using trace ID injection. The trace IDs injected into logs will automatically be converted to fully qualified IDs such as the ones described above, which may impact log parsing. Customers should inspect how their logs are consumed to make sure there won't be any difficulties upgrading.
Tested on sample app with Log4J and SLF4J loggers. Verified cross-thread propagation and nested subsegments work as expected.
Example
Would result in logs similar to this:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.