-
Notifications
You must be signed in to change notification settings - Fork 421
Bug: Tracing issues #4045
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
Comments
Hey @royassis! It's great to see you back here! 😊 After examining the exception and reviewing the code, it appears that the error originates from this line. I have a hypothesis regarding the cause, and I'd like to confirm it with you. 1 - Are you running this code locally? I'm asking because I noticed the presence of the 2 - Are you using a Powertools version prior to 2.36.0? Starting from version 2.36.0, we automatically disable the X-Ray tracer in environments such as Chalice and AWS SAM to prevent this type of error. I used this code in my Lambda function and it worked as expected: from aws_lambda_powertools import Tracer
from aws_lambda_powertools.utilities.typing import LambdaContext
from pymongo import MongoClient
tracer = Tracer()
@tracer.capture_method
def db_conn():
uri = "mongodb+srv://USER:[email protected]/?retryWrites=true&w=majority&appName=test-powertools"
mongodb_client = MongoClient(uri)
return mongodb_client
@tracer.capture_lambda_handler
def lambda_handler(event: dict, context: LambdaContext) -> str:
conn = db_conn()
print(conn.server_info())
return {"test": "ok"} Thanks |
Thanks @leandrodamascena :) Issue resolved |
|
Expected Behaviour
Traceback is not being logged or raised
Current Behaviour
Traceback attached below is being logged and raised, when the pymongo package and tracing is being used in code.
Code snippet
Possible Solution
No response
Steps to Reproduce
Create a function and initialize connection to mongodb database with pymongo.
Use tracer.capture_lambda_handler and tracer.capture_method.
Where:
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.11
Packaging format used
PyPi
Debugging logs
No response
The text was updated successfully, but these errors were encountered: