sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

Cannot make Sentry work with Google Cloud Function (python 3.9)

Open NicolasMarlier opened this issue 2 years ago • 2 comments

How do you use Sentry?

Sentry Saas (sentry.io)

Version

1.9.10

Steps to Reproduce

# main.py
import sentry_sdk
from sentry_sdk.integrations.gcp import GcpIntegration

sentry_sdk.init(
    dsn="https://***@***.ingest.sentry.io/***",
    integrations=[GcpIntegration()]
)

def main(request):
    return 1 / 0
# requirements.txt
sentry-sdk==1.9.10
# deploy.sh
gcloud functions deploy test_gcf_sentry \
--trigger-http \
--runtime=python39 \
--entry-point=main \
--memory=1GB \
--security-level=secure-always \
--region=europe-west1

Expected Result

Exception should be ingested in Sentry interface

Actual Result

Exception does not appear in Sentry interface

NicolasMarlier avatar Oct 06 '22 09:10 NicolasMarlier

link to stackoverflow: https://stackoverflow.com/questions/73970481/cannot-make-sentry-work-with-google-cloud-function-python-3-9

NicolasMarlier avatar Oct 06 '22 09:10 NicolasMarlier

(working fine with python 3.7)

NicolasMarlier avatar Oct 06 '22 10:10 NicolasMarlier

Sentry should work to some certain degree in 3.9. There is a warning in the code that the GcpIntegration only supports 3.7 at the moment, although, it would be nice to have this constraint be more prominently listed on the Sentry documentation.

Additionally, it would also be useful to note why this limitation exists, and a timeline for when other versions will be supported.

rushilsrivastava avatar Oct 15 '22 04:10 rushilsrivastava

Hey folks, as stated in the docs, we currently only support 3.7 for Google Cloud Functions. We have support for newer runtimes in our backlog and will track the progress in https://github.com/getsentry/sentry-python/issues/1667 once we get to it, but please note that this will take some time and we can't give you an estimate at the moment.

sentrivana avatar Nov 06 '23 10:11 sentrivana

Hey folks, as stated in the docs, we currently only support 3.7 for Google Cloud Functions. We have support for newer runtimes in our backlog and will track the progress in #1667 once we get to it, but please note that this will take some time and we can't give you an estimate at the moment.

Python 3.7 has passed its end of life on June 27, 2023. Its quite unfortunate that this still doesn't have an appropriate workaround. From my suggestions previously, it would be great if:

  • ~~Sentry could explicitly warn this when running the integration on a version higher than 3.7~~ (Edit: This happens now)
  • There could be additional insight into why this limitation exists and what would be needed to fix it
  • Any potential workarounds (one work around is just enabling the FlaskIntegration for example)

rushilsrivastava avatar Nov 14 '23 01:11 rushilsrivastava

Hey @rushilsrivastava, I'll update the docs with possible workarounds.

As for why the limitation exists, the integration as it's written now needs worker_v1, as long as that doesn't exist (as is the case for newer runtimes, apparently) the integration won't work. The integration itself was added a long time ago by a contributor in https://github.com/getsentry/sentry-python/pull/785. We need to find some time to look at it and investigate what's needed in order to support newer runtimes.

sentrivana avatar Nov 14 '23 14:11 sentrivana