improv(tracer): set AWS_XRAY_CONTEXT_MISSING
to IGNORE_ERROR
when no value is set
#3058
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Changes
This PR updates the Tracer utility to set the
AWS_XRAY_CONTEXT_MISSING
environment variable toIGNORE_ERROR
by default.This change has been made in response to customers adopting features that rely on top-level await and finding the error logs produced by X-Ray SDK not useful.
The X-Ray SDK for Node.js was not designed with this feature in mind, and by default it logs an error when a code path attempts to send trace data outside of the context of a request.
This is because without the request context, there's no X-Ray Trace ID, and so the SDK is unable to establish the lineage of a segment/span.
In many cases this is a desired behavior (although I'd have preferred it was a warning rather than an error log), however now that making async operations during the init phase is possible, it's not uncommon to make outbound http requests or use the AWS SDK to retrieve data or perform setup operations.
In those cases, the auto instrumentation features of Tracer (& the underlying X-Ray SDK) attempt to create a segment for these operations but don't find one because these tasks are run during the init phase, and thus outside of the context of a request.
The change has been made with backwards compatibility in mind, to an extent. Before setting the value we check if the env variable is already set and if so, we leave it as-is.
I believe this is a good middle ground between furthering our features and maintaining flexibility.
Issue number: closes #2406
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.