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

feat(tracer): auto-disable tracer when for AWS SAM and Chalice environments #3949

Merged

Conversation

leandrodamascena
Copy link
Contributor

Issue number: #3642

Summary

Changes

This pull request introduces the feature of automatically disable the Tracer when operating within AWS SAM and Chalice environments.

Changes Made

  • Added logic to detect AWS SAM and Chalice environments.
  • Updated relevant documentation to reflect the new behavior.

User experience

Before

sam local invoke --event events/event.json --skip-pull-image
Invoking app.lambda_handler (python3.10)                                                                                                                                                                                                                                                                                 
Requested to skip pulling images ...                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                         
Mounting /tmp/tracer/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated, inside runtime container                                                                                                                                                                                                               
START RequestId: 73b2e7bb-877b-42db-a86a-453d4c976172 Version: $LATEST
[WARNING]	2024-03-13T17:04:37.159Z	73b2e7bb-877b-42db-a86a-453d4c976172	Subsegment ## lambda_handler discarded due to Lambda worker still initializing
[WARNING]	2024-03-13T17:04:37.160Z	73b2e7bb-877b-42db-a86a-453d4c976172	No subsegment to end.
END RequestId: 73b2e7bb-877b-42db-a86a-453d4c976172
REPORT RequestId: 73b2e7bb-877b-42db-a86a-453d4c976172	Init Duration: 0.09 ms	Duration: 578.13 ms	Billed Duration: 579 ms	Memory Size: 128 MB	Max Memory Used: 128 MB	
"dummy payment collected for charge: "

After

sam local invoke --event events/event.json --skip-pull-image
Invoking app.lambda_handler (python3.10)                                                                                                                                                                                                                                                                                 
Requested to skip pulling images ...                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                         
Mounting /tmp/tracer/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated, inside runtime container                                                                                                                                                                                                               
START RequestId: 6def6c92-c55c-44bd-acd6-84414286e151 Version: $LATEST
END RequestId: 6def6c92-c55c-44bd-acd6-84414286e151
REPORT RequestId: 6def6c92-c55c-44bd-acd6-84414286e151	Init Duration: 0.11 ms	Duration: 484.16 ms	Billed Duration: 485 ms	Memory Size: 128 MB	Max Memory Used: 128 MB	
"dummy payment collected for charge: "

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

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.

@leandrodamascena leandrodamascena requested a review from a team as a code owner March 13, 2024 17:11
@boring-cyborg boring-cyborg bot added commons documentation Improvements or additions to documentation tests tracer Tracer utility labels Mar 13, 2024
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 13, 2024
@github-actions github-actions bot added feature New feature or functionality and removed documentation Improvements or additions to documentation labels Mar 13, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.33%. Comparing base (e14e768) to head (d104136).
Report is 170 commits behind head on develop.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3949      +/-   ##
===========================================
- Coverage    96.38%   96.33%   -0.05%     
===========================================
  Files          214      215       +1     
  Lines        10030    10255     +225     
  Branches      1846     1913      +67     
===========================================
+ Hits          9667     9879     +212     
- Misses         259      269      +10     
- Partials       104      107       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Mar 14, 2024
Copy link

sonarcloud bot commented Mar 14, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Mar 14, 2024
Copy link
Contributor

@rubenfonseca rubenfonseca left a comment

Choose a reason for hiding this comment

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

This looks very good, but didn't you mention skipping on Amplify too?

@leandrodamascena
Copy link
Contributor Author

This looks very good, but didn't you mention skipping on Amplify too?

Yes, you're right! But I tested locally and didn't see the environment variable, so I'd rather wait, have more time to test and make sure we're not doing anything wrong. I'll open another PR if needed, ok?

@leandrodamascena leandrodamascena merged commit 9e30192 into aws-powertools:develop Mar 19, 2024
16 checks passed
@leandrodamascena leandrodamascena deleted the autodisable-tracer branch March 19, 2024 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commons feature New feature or functionality size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests tracer Tracer utility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto-disable not happening when running outside AWS Lambda environment
3 participants