Tryton

(New in version 0.14.0)

The Tryton integration adds support for the Tryton Framework Server.

To configure the SDK, initialize it with the integration in a custom wsgi.py script:

Copied
# wsgi.py
import sentry_sdk
import sentry_sdk.integrations.trytond

sentry_sdk.init(
    desn="https://examplePublicKey@o0.ingest.sentry.io/0",
    integrations=[sentry_sdk.integrations.trytond.TrytondWSGIIntegration()]
)

from trytond.application import app as application

# ...

In Tryton>=5.4 an error handler can be registered to respond the client with a custom error message including the Sentry event id instead of a traceback.

Copied
# wsgi.py
# ...

from trytond.exceptions import TrytonException
from trytond.exceptions import UserError

@application.error_handler
def _(app, request, e):
    if isinstance(e, TrytonException):
        return
    else:
        event_id = sentry_sdk.last_event_id()
        data = UserError('Custom message', f'{event_id}\n{e}')
        return app.make_response(request, data)

Behavior

  • The Sentry Python SDK will install the Tryton integration. The integration hooks to the TrytonWSGI class' instance.

  • All uncaught exceptions not inherited from Tryton exceptions are reported.

  • Request data is attached to all events: HTTP method, URL, headers, form data, JSON payloads. Sentry excludes raw bodies and multipart file uploads. Sentry also excludes personally identifiable information (such as user ids, usernames, cookies, authorization headers, IP addresses) unless you set send_default_pii to True.

Each request has a separate scope. Changes to the scope within a view, for example setting a tag, will only apply to events sent as part of the request being handled.

You can edit this page on GitHub.