Pyramid
(New in version 0.5.0)
The Pyramid integration adds support for the Pyramid Web Framework. It requires Pyramid 1.6 or later.
Install
Install sentry-sdk
from PyPI:
pip install --upgrade sentry-sdk
Configure
To configure the SDK, initialize it with the integration before or after your app has been created:
import sentry_sdk
from sentry_sdk.integrations.pyramid import PyramidIntegration
sentry_sdk.init(
dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
integrations=[PyramidIntegration()]
)
from pyramid.config import Configurator
with Configurator() as config:
# ...
Behavior
The Sentry Python SDK will install the Pyramid integration for all of your apps. The integration hooks into Pyramid itself, not any of your apps specifically.
The SDK will report all exceptions leading to an Internal Server Error. These two kinds of exceptions are:
- exceptions that are not handled by any exception view
- exceptions whose exception view returns a status code of 500 (Pyramid version 1.9+ only)
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
toTrue
.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.
Logging with any logger will create breadcrumbs when the Logging integration is enabled (done by default).
Options
You can pass the following keyword arguments to PyramidIntegration()
:
transaction_style
:Copiedconfig.add_route("myroute", "/myurl/{id}") config.add_view(myfunction, route_name="myroute")
In the above code, you can set the transaction to:
/myurl/{id}
if you settransaction_style="route_pattern"
myroute
if you settransaction_style="route_name"
The default is
"route_name"
.
- Package:
- pypi:sentry-sdk
- Version:
- 2.12.0
- Repository:
- https://github.com/getsentry/sentry-python