Open fafrd opened 1 year ago
This seems to only happen on Lambda cold starts
Ok, this is happening when I have a decorator on the Lambda handler which pulls in another library. It can be recreated like this:
@sentry_initialize()
def handler(event, context):
...
from functools import wraps
import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
def sentry_initialize(function_name):
def decorator(function):
@wraps(function)
def wrapper(*args, **kwargs):
sentry_sdk.init(
dsn=SENTRY_DSN,
debug=False,
integrations=[
AwsLambdaIntegration(timeout_warning=True),
],
traces_sample_rate=1.0, # Capture all traces
)
sentry_sdk.set_tag("function_name", function_name)
# then call the function
return function(*args, **kwargs)
return wrapper
return decorator
When I change sentry_initialize
to not be a decorator- instead call this method manually inside the module- the code works as expected.
I'm trying to use Sentry alongside Serverless and having a pretty bad time. Getting flaky failures when calling sentry_sdk.init:
Multiple different components of the library seem to cause this:
point of failure is here: https://github.com/serverless/console/blob/main/python/packages/aws-lambda-sdk/serverless_aws_lambda_sdk/instrument/__init__.py#L590