Skip to content

Commit

Permalink
Python: Getting Started falcon
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Sep 15, 2023
1 parent a0da128 commit aac77c6
Showing 1 changed file with 51 additions and 8 deletions.
59 changes: 51 additions & 8 deletions src/platforms/python/guides/falcon/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,52 @@ The integration has been confirmed to work with Falcon 1.4 and 2.0.
Install `sentry-sdk` from PyPI with the `falcon` extra:

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

## Configure

To configure the SDK, initialize it with the integration before your app has been initialized:
If you have the `falcon` package in your dependencies, the Falcon integration will be enabled automatically. There is nothing to do for you except initializing the Sentry SDK.

<SignInNote />

```python
import falcon

import sentry_sdk
from sentry_sdk.integrations.falcon import FalconIntegration

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[
FalconIntegration(),
],

# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production,
traces_sample_rate=1.0,
)

api = falcon.API()
```

## Verify
```python
import falcon

sentry_sdk.init(...) # same as above

class HelloWorldResource:
def on_get(self, req, resp):
message = {
'hello': "world",
}
1 / 0 # raises an error
resp.media = message

app = falcon.App()
app.add_route('/', HelloWorldResource())
```

When you point your browser to [http://localhost:8000/](http://localhost:8000/) a transaction in the Performance section of [sentry.io](https://sentry.io) will be created. Additionally an error event will be sent to [sentry.io](https://sentry.io) and will be connected to the transaction.

It takes a couple of moments for the data to appear in [sentry.io](https://sentry.io).

## 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.
Expand All @@ -54,6 +71,26 @@ api = falcon.API()

## Options

By adding `FalconIntegration` explicitly to your `sentry_sdk.init()` call you can set options for `FalconIntegration` to change its behavior:

```python
import sentry_sdk
from sentry_sdk.integrations.falcon import FalconIntegration

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=1.0,
integrations = [
FalconIntegration(
transaction_style="path",
),
],
)
```


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

- `transaction_style`:
Expand All @@ -74,3 +111,9 @@ You can pass the following keyword arguments to `FalconIntegration()`:
- `/myurl/{message_id}` if you set `transaction_style="uri_template"`

The default is `"uri_template"`.


## Supported Versions

- Falcon: 1.4+
- Python: 2.7+ (Falcon 1.4+), 3.5+ (Falcon 3.0+)

0 comments on commit aac77c6

Please sign in to comment.