Code Monkey home page Code Monkey logo

Comments (3)

leandrodamascena avatar leandrodamascena commented on August 9, 2024 2

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.

boring-cyborg avatar boring-cyborg commented on August 9, 2024

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.

leandrodamascena avatar leandrodamascena commented on August 9, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.