From aac77c6d1103f5b8e9e71cfcfd4085f9692612c3 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Fri, 15 Sep 2023 12:14:41 +0200 Subject: [PATCH 1/3] Python: Getting Started falcon --- src/platforms/python/guides/falcon/index.mdx | 59 +++++++++++++++++--- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/src/platforms/python/guides/falcon/index.mdx b/src/platforms/python/guides/falcon/index.mdx index e393aabbdcc4d..8c43af9921d27 100644 --- a/src/platforms/python/guides/falcon/index.mdx +++ b/src/platforms/python/guides/falcon/index.mdx @@ -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. ```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. @@ -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`: @@ -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+) From e51989ac4d237295920cec2702bb324ca3c74d7a Mon Sep 17 00:00:00 2001 From: "getsantry[bot]" <66042841+getsantry[bot]@users.noreply.github.com> Date: Wed, 20 Sep 2023 11:40:57 +0000 Subject: [PATCH 2/3] style(lint): Auto commit lint changes --- src/platforms/python/guides/falcon/index.mdx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/platforms/python/guides/falcon/index.mdx b/src/platforms/python/guides/falcon/index.mdx index 8c43af9921d27..25e6eb7c95635 100644 --- a/src/platforms/python/guides/falcon/index.mdx +++ b/src/platforms/python/guides/falcon/index.mdx @@ -38,6 +38,7 @@ api = falcon.API() ``` ## Verify + ```python import falcon @@ -90,7 +91,6 @@ sentry_sdk.init( ) ``` - You can pass the following keyword arguments to `FalconIntegration()`: - `transaction_style`: @@ -112,7 +112,6 @@ You can pass the following keyword arguments to `FalconIntegration()`: The default is `"uri_template"`. - ## Supported Versions - Falcon: 1.4+ From 6e3d9263ceba9fffc1d1228f434855f503834d70 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Thu, 21 Sep 2023 08:36:59 +0200 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Shana Matthews --- src/platforms/python/guides/falcon/index.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platforms/python/guides/falcon/index.mdx b/src/platforms/python/guides/falcon/index.mdx index 25e6eb7c95635..7d05607999bb0 100644 --- a/src/platforms/python/guides/falcon/index.mdx +++ b/src/platforms/python/guides/falcon/index.mdx @@ -18,7 +18,7 @@ pip install --upgrade 'sentry-sdk[falcon]' ## Configure -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. +If you have the `falcon` package in your dependencies, the Falcon integration will be enabled automatically when you initialize the Sentry SDK. @@ -56,7 +56,7 @@ 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. +When you point your browser to [http://localhost:8000/](http://localhost:8000/) a transaction will be created in the Performance section of [sentry.io](https://sentry.io). 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). @@ -72,7 +72,7 @@ It takes a couple of moments for the data to appear in [sentry.io](https://sentr ## Options -By adding `FalconIntegration` explicitly to your `sentry_sdk.init()` call you can set options for `FalconIntegration` to change its behavior: +By adding `FalconIntegration` to your `sentry_sdk.init()` call explicitly, you can set options for `FalconIntegration` to change its behavior: ```python import sentry_sdk