Skip to content
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

Merged
merged 2 commits into from
Jan 22, 2021

Conversation

mfriesen
Copy link
Contributor

*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.

Copy link
Contributor

@willarmiros willarmiros left a 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));
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor Author

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));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep exactly like that!

@mfriesen
Copy link
Contributor Author

@willarmiros I have updated the PR with your comments. Please let me know if you need anything else changed.

Copy link
Contributor

@willarmiros willarmiros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants