-
Notifications
You must be signed in to change notification settings - Fork 14
Add trace log correlation #21
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
Conversation
| @@ -1,5 +1,6 @@ | |||
| package com.datadoghq.datadog_lambda_java; | |||
|
|
|||
| import org.slf4j.MDC; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a standard logging solution? Or are we forcing people to add it as a dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slf4j is a standard logging facade that unifies the most common java logging frameworks (log4j, java.util.logging, logback, etc). Our users aren't forced to use it; they can get the trace ID as a raw string and incorporate it however they want.
src/test/java/com/datadoghq/datadog_lambda_java/TraceLogCorrelationTest.java
Outdated
Show resolved
Hide resolved
|
|
||
| @Test | ||
| public void getAPMTraceID() { | ||
| XRayTraceContext xrt = new XRayTraceContext(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look good. They are the same tests we have in the other languages right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I ported these from Go directly
|
@DarcyRaynerDD , to confirm, the span ID is the parent ID, correct? |
DarcyRaynerDD
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. Left a nit on the docs
README.md
Outdated
| #### Plain text logs | ||
|
|
||
| If you are using plain text logs, then you must create a new [Parser](https://docs.datadoghq.com/logs/processing/parsing/?tab=matcher) | ||
| that can extract the trace context from the correct position in the logs. Use the helper `_trace_context` to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth noting that this helper is only available if you are modifying our Lambda pipeline, with our existing grok rules.
What does this PR do?
This adds the capability to inject trace IDs into your logs so that you can correlate your logs with your traces.
In the case of XRay tracing, this calculates a DD Trace ID from the last 63 bits of the XRay trace ID. It exposes a method from within DDLambda that lets you get your trace ID. It also adds the trace ID to the slf4j MDC so that the trace ID can be accessed by Log4J or other logging frameworks.
Testing Guidelines
Done: Unit tests that instantiate a new DDLambda (w/XRay tracing) and attempt to log some things using Log4J, verifying that the trace ID was added to the logs. Created a test lambda using log4j and verified it worked as expected.
Additional Notes
Types of changes
Checklist