File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313)
1414
1515with workflow .unsafe .imports_passed_through ():
16- from sentry_sdk import isolation_scope
16+ import sentry_sdk
1717
1818
1919logger = logging .getLogger (__name__ )
2222class _SentryActivityInboundInterceptor (ActivityInboundInterceptor ):
2323 async def execute_activity (self , input : ExecuteActivityInput ) -> Any :
2424 # https://docs.sentry.io/platforms/python/troubleshooting/#addressing-concurrency-issues
25- with isolation_scope () as scope :
25+ with sentry_sdk . isolation_scope () as scope :
2626 scope .set_tag ("temporal.execution_type" , "activity" )
2727 scope .set_tag ("module" , input .fn .__module__ + "." + input .fn .__qualname__ )
2828 activity_info = activity .info ()
@@ -50,7 +50,7 @@ async def execute_activity(self, input: ExecuteActivityInput) -> Any:
5050class _SentryWorkflowInterceptor (WorkflowInboundInterceptor ):
5151 async def execute_workflow (self , input : ExecuteWorkflowInput ) -> Any :
5252 # https://docs.sentry.io/platforms/python/troubleshooting/#addressing-concurrency-issues
53- with isolation_scope () as scope :
53+ with sentry_sdk . isolation_scope () as scope :
5454 scope .set_tag ("temporal.execution_type" , "workflow" )
5555 scope .set_tag (
5656 "module" , input .run_fn .__module__ + "." + input .run_fn .__qualname__
Original file line number Diff line number Diff line change 77from sentry_sdk .types import Event , Hint
88from temporalio .client import Client
99from temporalio .worker import Worker
10+ from temporalio .worker .workflow_sandbox import (
11+ SandboxedWorkflowRunner ,
12+ SandboxRestrictions ,
13+ )
1014
1115from sentry .activity import compose_greeting
1216from sentry .interceptor import SentryInterceptor
@@ -27,7 +31,7 @@ def before_send(event: Event, hint: Hint) -> Event | None:
2731
2832async def main ():
2933 # Configure logging
30- logging .basicConfig (level = logging .DEBUG )
34+ logging .basicConfig (level = logging .INFO )
3135
3236 # Initialize the Sentry SDK
3337 if sentry_dsn := os .environ .get ("SENTRY_DSN" ):
@@ -57,6 +61,11 @@ async def main():
5761 workflows = [GreetingWorkflow ],
5862 activities = [compose_greeting ],
5963 interceptors = [SentryInterceptor ()], # Use SentryInterceptor for error reporting
64+ workflow_runner = SandboxedWorkflowRunner (
65+ restrictions = SandboxRestrictions .default .with_passthrough_modules (
66+ "sentry_sdk"
67+ )
68+ ),
6069 ):
6170 # Wait until interrupted
6271 print ("Worker started, ctrl+c to exit" )
You can’t perform that action at this time.
0 commit comments