| Server IP : 198.54.126.161 / Your IP : 216.73.217.148 Web Server : LiteSpeed System : Linux premium12.web-hosting.com 4.18.0-553.94.1.lve.el8.x86_64 #1 SMP Thu Jan 22 12:37:22 UTC 2026 x86_64 User : amerfigf ( 898) PHP Version : 8.2.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/opt/hc_python/lib64/python3.12/site-packages/sentry_sdk/integrations/ |
Upload File : |
import sentry_sdk
from sentry_sdk.integrations import DidNotEnable, Integration
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
from sentry_sdk.utils import ensure_integration_enabled, event_from_exception
try:
from trytond.exceptions import TrytonException # type: ignore
from trytond.wsgi import app # type: ignore
except ImportError:
raise DidNotEnable("Trytond is not installed.")
# TODO: trytond-worker, trytond-cron and trytond-admin intergations
class TrytondWSGIIntegration(Integration):
identifier = "trytond_wsgi"
origin = f"auto.http.{identifier}"
def __init__(self) -> None:
pass
@staticmethod
def setup_once() -> None:
app.wsgi_app = SentryWsgiMiddleware(
app.wsgi_app,
span_origin=TrytondWSGIIntegration.origin,
)
@ensure_integration_enabled(TrytondWSGIIntegration)
def error_handler(e: 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)