-
Notifications
You must be signed in to change notification settings - Fork 99
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
Read _X_AMZN_TRACE_ID from environment & system properties #252
Conversation
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.
I'm ok with this change, just a small comment.
return TraceHeader.fromString(System.getenv(LAMBDA_TRACE_HEADER_KEY)); | ||
return TraceHeader.fromString(System.getenv(LAMBDA_TRACE_HEADER_KEY) != null | ||
? System.getenv(LAMBDA_TRACE_HEADER_KEY) | ||
: System.getProperty(LAMBDA_TRACE_HEADER_KEY)); |
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.
Perhaps we should introduce a string that's formatted as a more idiomatic system property key, e.g. com.amazonaws.xray.traceHeader
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.
And also if you could link #251 in a comment in the code so we know why this behavior is different for our java SDK than in other languages.
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.
I can definitely do that, but I'm not clear on what you are asking for? Are you asking for this?
private static final String LAMBDA_TRACE_HEADER_PROP = "com.amazonaws.xray.traceHeader";
return TraceHeader.fromString(System.getenv(LAMBDA_TRACE_HEADER_KEY) != null
? System.getenv(LAMBDA_TRACE_HEADER_KEY)
: System.getProperty(LAMBDA_TRACE_HEADER_PROP));
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.
Yep exactly like that!
…ronment variable is not set
@willarmiros I have updated the PR with your comments. Please let me know if you need anything else changed. |
aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/contexts/LambdaSegmentContext.java
Outdated
Show resolved
Hide resolved
…ntexts/LambdaSegmentContext.java
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.
LGTM
*Issue #251
Description of changes:
For custom runtimes that use this library, IE: graalvm. It's not possible to set the _X_AMZN_TRACE_ID as a environment property. By checking the system properties for _X_AMZN_TRACE_ID, if the environment property does not exist, this will allow the X-Ray to be able to be used by custom runtimes.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.