getsentry / sentry-python

The official Python SDK for Sentry.io
https://sentry.io/for/python/
MIT License
1.86k stars 486 forks source link

AWS Lambda Container Image (Python) #1244

Open GlennFischer032 opened 2 years ago

GlennFischer032 commented 2 years ago

Environment

How do you use Sentry? Sentry SaaS (sentry.io)

Which SDK and version? Python 3.8

Steps to Reproduce

  1. Followed steps on https://docs.sentry.io/platforms/python/guides/aws-lambda/container-image/
  2. Started lambda function with function code deployed as a container image

Expected Result

Sentry initializes normally

Actual Result

Lambda ended with Execution result: failed and returned

{
  "errorMessage": "Unable to import module 'sentry_sdk.integrations.init_serverless_sdk': No module named 'init_serverless_sdk'",
  "errorType": "Runtime.ImportModuleError",
  "stackTrace": []
}
kmeelu commented 2 years ago

Hi, I am also receiving the same issue, with the following initialization code.

import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration

from helpers import get_environment_variable

sentry_sdk.init(
    dsn=get_environment_variable("SENTRY_DSN"),
    environment=get_environment_variable("STAGE"),
    send_default_pii=True,
    integrations=[AwsLambdaIntegration()],
)
github-actions[bot] commented 2 years ago

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

antonpirker commented 2 years ago

Hello @GlennFischer032 and @kmeelu ! Sorry for not coming back to you sooner.

Do you still have this problem? Have you solved it, and if yes, how did you solve this? Thanks for your feedback!

And just as a heads up: we are planning to create a AWS Lambda Extension for a better experience with instrumenting AWS Lambda function, so stay tuned!

kevchentw commented 2 years ago

@antonpirker I got the same issue when I integrate with AWS Lambda Extension. I fix it by removing "sentry-sdk" in requirements.txt. I think only layer version of sentry-sdk have init_serverless_sdk module.

antonpirker commented 2 years ago

Ok, thanks for the info @kevchentw

I will put this in the internal backlog, we overhaul our serverless integration at the moment, so maybe we can also work on this.

juanmarin96 commented 2 years ago

I found that the installed version of public.ecr.aws/sentry/sentry-python-serverless-sdk:6 which is in the documentation is 1.3.0 image which has init_serverless_sdk module, but if you install the latest version 1.9.5 that module was removed, seems to be that the documentation and the package for integrate Sentry with Lamba Container is out date. Do you have any news about this?

zachwe commented 1 year ago

@antonpirker any update on this?

antonpirker commented 1 year ago

Unfortunately no news @zachwe . It is on our backlog, but right now we are quite swamped with other stuff.

emerson-h commented 1 year ago

We're encountering the same issue after installing sentry for lambda using the CloudFormation integration configured through the sentry.io UI.

This makes the sentry lambda integration effectively useless as it breaks all of our python 3.7 lambdas.

Execution fails at lambda startup with

[ERROR] Runtime.ImportModuleError: Unable to import module 'sentry_sdk.integrations.init_serverless_sdk': urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips  26 Jan 2017'. See: https://github.com/urllib3/urllib3/issues/2168