Falcon

(New in version 0.7.11)

The Falcon integration adds support for the Falcon Web Framework. The integration has been confirmed to work with Falcon 1.4 and 2.0.

Install

Install sentry-sdk from PyPI with the falcon extra:

Copied
pip install --upgrade 'sentry-sdk[falcon]==0.16.2'

Configure

To configure the SDK, initialize it with the integration before your app has been initialized:

Copied
import falcon
import sentry_sdk
from sentry_sdk.integrations.falcon import FalconIntegration

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

api = falcon.API()

Behavior

  • The Sentry Python SDK will install the Falcon integration for all of your apps. The integration hooks into the base falcon.API class via monkey patching.

  • All exceptions leading to an Internal Server Error 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.

Options

You can pass the following keyword arguments to FalconIntegration():

  • transaction_style:

    Copied
    class MessageResource:
        def on_get(self, req, resp, message_id):
            msg = database.get_message(message_id)
            resp.media = msg.as_json()
    
    app = falcon.API()
    app.add_route("/message/{message_id}", MessageResource())

    In the above code, you would set the transaction to:

    • /myurl/b48a7686-ad8c-4c94-8c3b-412ec7f25db2123 if you set transaction_style="path".
    • /myurl/{message_id} if you set transaction_style="uri_template"

    The default is "uri_template".