-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inject TraceID in to log messages #196
Comments
Hi @bruceharrison1984 Thanks! |
@srprash In the meantime, is there any other way to get application logs to show up in XRay Traces? |
@DanielLaberge I'm curious to know this as well. @srprash |
@DanielLaberge @bruceharrison1984
For the X-Ray .Net SDK, I believe it is still possible to do the 2nd part by fetching the trace-id and segment-id of the current segment and passing it into logger. However, the current resource plugins are missing the logic to get the CW log group ARN to enable ServiceLens to do the actual correlation. |
@srprash I appreciate you closing the loop on this 👍 |
I know it's an old thread, but I will comment anyway, as it can help others. After seeing this GitHub issue and comment in the aws-xray-sdk-python I decided to try the same on .NET SDK and got the same result. Here is what I did using Serilog. |
The Java SDK exposes AWS-XRAY-TRACE-ID in the MDC to allow for easily adding TraceID to log messages, which allows ServiceLens to marry up X-Ray segments and log messages. It would be great to have this same behavior within the C# library, or at least an easy to access value for adding traceId to log messages in a similar fashion.
From the Java X-Ray SDK:
To expose the current fully qualified trace ID to your log statements, you can inject the ID into the mapped diagnostic context (MDC). Using the SegmentListener interface, methods are called from the X-Ray recorder during segment lifecycle events. When a segment or subsegment begins, the qualified trace ID is injected into the MDC with the key AWS-XRAY-TRACE-ID. When that segment ends, the key is removed from the MDC. This exposes the trace ID to the logging library in use. When a subsegment ends, its parent ID is injected into the MDC.
https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java-configuration.html#xray-sdk-java-configuration-logging
The text was updated successfully, but these errors were encountered: