From aa7cf87c2a20d023b92da951b81abd0ebfe0552d Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Mon, 20 Oct 2025 08:56:48 +0200 Subject: [PATCH] fix(gcp): Inject scopes in TimeoutThread exception with GCP --- sentry_sdk/integrations/gcp.py | 7 ++++++- tests/integrations/gcp/test_gcp.py | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/gcp.py b/sentry_sdk/integrations/gcp.py index c637b7414a..2b0441f95d 100644 --- a/sentry_sdk/integrations/gcp.py +++ b/sentry_sdk/integrations/gcp.py @@ -75,7 +75,12 @@ def sentry_func(functionhandler, gcp_event, *args, **kwargs): ): waiting_time = configured_time - TIMEOUT_WARNING_BUFFER - timeout_thread = TimeoutThread(waiting_time, configured_time) + timeout_thread = TimeoutThread( + waiting_time, + configured_time, + isolation_scope=scope, + current_scope=sentry_sdk.get_current_scope(), + ) # Starting the thread to raise timeout warning exception timeout_thread.start() diff --git a/tests/integrations/gcp/test_gcp.py b/tests/integrations/gcp/test_gcp.py index d088f134fe..c27c7653aa 100644 --- a/tests/integrations/gcp/test_gcp.py +++ b/tests/integrations/gcp/test_gcp.py @@ -196,6 +196,7 @@ def test_timeout_error(run_cloud_function): functionhandler = None event = {} def cloud_function(functionhandler, event): + sentry_sdk.set_tag("cloud_function", "true") time.sleep(10) return "3" """ @@ -219,6 +220,8 @@ def cloud_function(functionhandler, event): assert exception["mechanism"]["type"] == "threading" assert not exception["mechanism"]["handled"] + assert envelope_items[0]["tags"]["cloud_function"] == "true" + def test_performance_no_error(run_cloud_function): envelope_items, _ = run_cloud_function(