-
Notifications
You must be signed in to change notification settings - Fork 146
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
feat(tracer): auto disable when running inside amplify mock #1010
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dreamorosi
commented
Jun 28, 2022
@@ -65,7 +65,7 @@ For a **complete list** of supported environment variables, refer to [this secti | |||
|
|||
#### Example using AWS Serverless Application Model (SAM) | |||
|
|||
The `Tracer` utility is instantiated outside of the Lambda handler. In doing this, the same instance can be used across multiple invocations inside the same execution environment. This allows `Metrics` to be aware of things like whether or not a given invocation had a cold start or not. | |||
The `Tracer` utility is instantiated outside of the Lambda handler. In doing this, the same instance can be used across multiple invocations inside the same execution environment. This allows `Tracer` to be aware of things like whether or not a given invocation had a cold start or not. |
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.
Housekeeping
📊 Package size report 0.2%↑
🤖 This report was automatically generated by pkg-size-action |
flochaz
approved these changes
Jul 4, 2022
ijemmy
approved these changes
Jul 8, 2022
dreamorosi
added a commit
that referenced
this pull request
Aug 2, 2022
* feat: disable tracer when running in amplify mock * chore: housekeeping typo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of your changes
As discussed in #1007, the Amplify CLI allows developers to run Lambda functions locally during development. When not running inside the AWS Lambda execution environment the
xray-sdk
, and by extensionTracer
, will not be able to work properly as there isn't any X-Ray Daemon to connect to and send traces. Unless explicitly accounted for, the default behaviour of the SDK is to throw an exception.This is a problem as it requires developers using Tracer to make changes to their code only to be able to test locally. Similarly to what we already do with SAM CLI, in this PR I introduced some logic to leverage a special value set by the Amplify CLI in the environment variables (details here) to detect that Tracer is indeed running inside a process started by the Amplify CLI and automatically disable itself to avoid attempting to send traces and segments.
When merged this PR will close #1007.
How to verify this change
Check the newly added test cases as well as the result of the e2e tests (link in the comments below).
Related issues, RFCs
#1007
PR status
Is this ready for review?: YES
Is it a breaking change?: NO
Checklist
Breaking change checklist
N/A
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.