Comments (3)
Hey @bepetersn! Thanks for bringing up this question! Let me start by saying that the reason we disable Tracer outside of the Lambda environment is that we rely on the Root Segment created by Lambda and then we can create subsegments from it. We may need to investigate how to allow customers to use our Tracer utility outside of the Lambda environment, but this is the behavior for now.
Just out of curiosity and before I continue the explanation, how is this impacting your experience or environment? I'm interested in hearing this and seeing if we can think of any solutions or something else.
Possible Solution
I can get these warnings to go away by specifying an environment variable, as described here: #1898 (
POWERTOOLS_TRACE_DISABLED
), however this doesn't satisfy the documentation's claim that tracer is auto-disabled when not running in an AWS Lambda environment.
The reason this is happening is that we verify if it is a Lambda environment by checking the LAMBDA_TASK_ROOT
env variable and AWS SAM also sets this variable. I don't have the information of whether this was intentional or not, not disabling Tracer in AWS SAM and I need to talk to my peers. However, it seems to make sense to disable it too, since we don't have the root segment in AWS SAM and X-Ray SDK emits these warnings.
For example, the log
Subsegment dynamodb discarded due to Lambda worker still initializing
isn't obviously being generated by the powertools library--although maybe it is. You all would know better.
However, I still see logs that look like below. I am very confident this is coming from Powertools:
Subsegment ## lambda_handler discarded due to Lambda worker still initializing
This is generated by X-Ray SDK when Powertools try to create a subsegment.
Is the documentation incorrect? Is the environment variable required?
With that explained, it would be interesting to hear from other maintainers and the community if we need to verify that it is running in a SAM environment and disable the Tracer utility, or update our documentation to add SAM as an exception. I'm adding labels to classify this issue.
Thanks.
from powertools-lambda-python.
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link
from powertools-lambda-python.
Hi @bepetersn! Thanks for your patience and helping us to make Powertools for AWS Lambda even better! I have spoken to my colleagues and we will revert to this PR that removed the SAM CLI environment check.
Additionally, Powertools for AWS Lambda (TypeScript) has an additional check to validate that it is an Amplify environment too. We can add it in the same way.
Do you want to send a PR to add this? We'd love to have your first contribution here.
from powertools-lambda-python.
Related Issues (20)
- [I Made This]: Creating a serverless API using AWS Lambda Powertools and CDK HOT 6
- bug: Swagger UI is breaking with certain characters HOT 5
- Feature: Event handler Swagger doesnt add 422 response to openapi when adding custom responses HOT 3
- Bug: Can't install with pyndantic >2.0 (despite documentation saying otherwise) HOT 10
- Maintenance: Deprecate Python 3.7 HOT 2
- DOCS: Add a banner to our documentation stating that we are dropping support for Python 3.7 HOT 2
- Bug: OpenAPI doesnt support multiValueQueryStringParameters HOT 2
- Feature Request: Add support for new policyLevel field in Cloudwatch Logs Event Source and Parse HOT 2
- Maintenance: Bump boto3 library to 1.26.164+ HOT 2
- Feature: Add security schemes, headers, cookies, form and files in OpenAPI schema HOT 2
- Maintenance: Drop Python 3.7 support in our pipelines, pyproject.toml and clean up the code HOT 1
- Docs: Missing closing ``` from function comment HOT 4
- Maintenance: Disable Redis e2e tests HOT 2
- Feature request: Add support for headers parameters in OpenAPI schema HOT 3
- Feature request: Add support for Authentication and Authorization in OpenAPI schema HOT 1
- Feature request: Add support for Files and Form in OpenAPI schema HOT 1
- Docs: fix empty metric warning filter HOT 1
- Bug: REST Event Handler doesn't handle some json parsing exceptions HOT 5
- Maintenance: Create maintenance and versioning policy guide HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from powertools-lambda-python.