You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use Sentry with Temporal to track and manage warnings within workflows.
Describe the bug
Sentry’s catch_warnings context manager, which relies on the standard Python warnings module, raises a KeyError in Temporal workflows because the warnings module is not available. This happens in environments managed by Temporal, which restricts access to certain standard Python modules like warnings.
This restriction leads to a failure when using libraries like Sentry that depend on this module for capturing and managing Python warnings.
Error Example:
KeyError: 'warnings'
Cause: The warnings module is not present or accessible within the Temporal workflow environment, causing the code to fail when it tries to reference sys.modules['warnings'].
Minimal Reproduction
To reproduce this issue:
1. Set up a Temporal workflow in Python.
2. Integrate Sentry’s catch_warnings context manager or any other library that uses the warnings module.
3. Trigger a Python warning within the workflow (e.g., by using warnings.warn()).
4. The workflow fails with a KeyError: 'warnings' due to the restricted access.
Here’s a minimal code snippet:
def workflow_function():
with warnings.catch_warnings(record=True) as w:
warnings.warn("This is a test warning")
Environment/Versions
• OS and processor: MacBook Pro M1
• Temporal Version: 1.7.1
• Are you using Docker or Kubernetes?: Using Docker to run Temporal
The text was updated successfully, but these errors were encountered:
Integrate Sentry’s catch_warnings context manager or any other library that uses the warnings module.
You're going to have to pass through the imports and disable the sandbox I believe. warnings is not a determinism-safe module (and Sentry likely isn't either). Using non-deterministic modules like Sentry require pass through and sandbox avoidance. https://github.com/temporalio/sdk-python?tab=readme-ov-file#workflow-sandbox explains how the sandbox works and how to disable for parts of code. Similar pass through and avoidance techniques are applied in our Sentry interceptor in the sample at https://github.com/temporalio/samples-python/tree/main/sentry.
What are you really trying to do?
Use Sentry with Temporal to track and manage warnings within workflows.
Describe the bug
Sentry’s catch_warnings context manager, which relies on the standard Python warnings module, raises a KeyError in Temporal workflows because the warnings module is not available. This happens in environments managed by Temporal, which restricts access to certain standard Python modules like warnings.
This restriction leads to a failure when using libraries like Sentry that depend on this module for capturing and managing Python warnings.
Error Example:
Cause: The warnings module is not present or accessible within the Temporal workflow environment, causing the code to fail when it tries to reference sys.modules['warnings'].
Minimal Reproduction
To reproduce this issue:
Here’s a minimal code snippet:
Environment/Versions
The text was updated successfully, but these errors were encountered: