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 system properties if environment variable is not set #251

Closed
Morras opened this issue Jan 20, 2021 · 3 comments
Closed

Comments

@Morras
Copy link

Morras commented Jan 20, 2021

Using a custom Lambda runtime, you are required to set the _X_AMZN_TRACE_ID environment variable on each request.

In Java there is no easy way of setting environment variables at runtime, this StackOverflow post details some of the hacks and edge cases you need to work around to get this to work.

The Lambda custom runtime documentation clearly says this should be an environment variable, but would it be possible to create a fallback for the Java SDK, where in case the environment variable is not set, it will check the system properties?

The relevant SDK code is line 40 in LambdaSegmentContext.

Having system properties as a fallback would still compatible with the documentation and any implementation using environment variables, but future Java implementations would not need to circumvent the environment variables system in Java.

mfriesen added a commit to mfriesen/aws-xray-sdk-java that referenced this issue Jan 21, 2021
willarmiros added a commit that referenced this issue Jan 22, 2021
* Issue: #251 - Read _X_AMZN_TRACE_ID from system properties if environment variable is not set

* Update aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/contexts/LambdaSegmentContext.java

Co-authored-by: William Armiros <[email protected]>
mfriesen added a commit to formkiq/lambda-runtime-graalvm that referenced this issue Jan 22, 2021
aws-xray renamed _X_AMZN_TRACE_ID environment property to  System Property com.amazonaws.xray.traceHeader
aws/aws-xray-sdk-java#251
mfriesen added a commit to formkiq/lambda-runtime-graalvm that referenced this issue Jan 22, 2021
aws-xray renamed _X_AMZN_TRACE_ID environment property to  System Property com.amazonaws.xray.traceHeader
aws/aws-xray-sdk-java#251
@FieryCod
Copy link

@willarmiros Do you maybe know when this feature is gonna be published?

@bhautikpip bhautikpip self-assigned this Jul 20, 2021
@bhautikpip
Copy link
Contributor

Probably you can use the latest snapshot (https://aws.oss.sonatype.org/content/repositories/snapshots/) to consume this enhancement and that will unblock you temporararily while waiting for the actual release. We publish snapshot on every merge to master branch.

@smirnoal
Copy link

is this issue still relevant? has reading from system props logic landed any release?

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

No branches or pull requests

6 participants