aboutsummaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/sentry_sdk/integrations/trytond.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/sentry_sdk/integrations/trytond.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-master.tar.gz
two version of R2R are hereHEADmaster
Diffstat (limited to '.venv/lib/python3.12/site-packages/sentry_sdk/integrations/trytond.py')
-rw-r--r--.venv/lib/python3.12/site-packages/sentry_sdk/integrations/trytond.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/sentry_sdk/integrations/trytond.py b/.venv/lib/python3.12/site-packages/sentry_sdk/integrations/trytond.py
new file mode 100644
index 00000000..2c44c593
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/sentry_sdk/integrations/trytond.py
@@ -0,0 +1,50 @@
+import sentry_sdk
+from sentry_sdk.integrations import Integration
+from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
+from sentry_sdk.utils import ensure_integration_enabled, event_from_exception
+
+from trytond.exceptions import TrytonException # type: ignore
+from trytond.wsgi import app # type: ignore
+
+
+# TODO: trytond-worker, trytond-cron and trytond-admin intergations
+
+
+class TrytondWSGIIntegration(Integration):
+ identifier = "trytond_wsgi"
+ origin = f"auto.http.{identifier}"
+
+ def __init__(self): # type: () -> None
+ pass
+
+ @staticmethod
+ def setup_once(): # type: () -> None
+ app.wsgi_app = SentryWsgiMiddleware(
+ app.wsgi_app,
+ span_origin=TrytondWSGIIntegration.origin,
+ )
+
+ @ensure_integration_enabled(TrytondWSGIIntegration)
+ def error_handler(e): # type: (Exception) -> None
+ if isinstance(e, TrytonException):
+ return
+ else:
+ client = sentry_sdk.get_client()
+ event, hint = event_from_exception(
+ e,
+ client_options=client.options,
+ mechanism={"type": "trytond", "handled": False},
+ )
+ sentry_sdk.capture_event(event, hint=hint)
+
+ # Expected error handlers signature was changed
+ # when the error_handler decorator was introduced
+ # in Tryton-5.4
+ if hasattr(app, "error_handler"):
+
+ @app.error_handler
+ def _(app, request, e): # type: ignore
+ error_handler(e)
+
+ else:
+ app.error_handlers.append(error_handler)