---
title: "Tryton"
description: "Learn aboutn using Sentry with Tryton."
url: https://docs.sentry.io/platforms/python/integrations/tryton/
---

# Tryton for Python

The Tryton integration adds support for the [Tryton Framework Server](https://www.tryton.org/).

## [Configure](https://docs.sentry.io/platforms/python/integrations/tryton.md#configure)

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

In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](https://docs.sentry.io/concepts/key-terms/tracing.md). You can also collect and analyze performance profiles from real users with [profiling](https://docs.sentry.io/product/profiling.md).

Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.

Error Monitoring\[ ]Tracing\[ ]Profiling

```python
# wsgi.py
import sentry_sdk
from sentry_sdk.integrations.trytond import TrytondWSGIIntegration

sentry_sdk.init(
    dsn="https://<key>@o<orgId>.ingest.sentry.io/<projectId>",
    # Add data like request headers and IP for users, if applicable;
    # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
    send_default_pii=True,
    # ___PRODUCT_OPTION_START___ performance
    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for tracing.
    traces_sample_rate=1.0,
    # ___PRODUCT_OPTION_END___ performance
    # ___PRODUCT_OPTION_START___ profiling
    # To collect profiles for all profile sessions,
    # set `profile_session_sample_rate` to 1.0.
    profile_session_sample_rate=1.0,
    # Profiles will be automatically collected while
    # there is an active span.
    profile_lifecycle="trace",
    # ___PRODUCT_OPTION_END___ profiling
    integrations=[
        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.

```python
# wsgi.py
# ...

from trytond.exceptions import TrytonException, 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](https://docs.sentry.io/platforms/python/integrations/tryton.md#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.

## [Supported Versions](https://docs.sentry.io/platforms/python/integrations/tryton.md#supported-versions)

* Tryton:

  * 4.6+ (SDK <3.0)
  * 5.4+ (SDK 3.0+)

* Python:

  * 3.6+ (SDK <3.0)
  * 3.7+ (SDK 3.0+)

If you're looking to use Sentry with older Python or framework versions, consider using an older major version of the SDK. The minimum versions for each major version are listed above.
