Skip to content

Commit fff000f

Browse files
Python: Getting Started bottle (#7824)
* Python: Getting Started bottle * update * Update index.mdx * Update index.mdx * Apply suggestions from code review Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com> --------- Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com>
1 parent 192112e commit fff000f

File tree

1 file changed

+49
-10
lines changed

1 file changed

+49
-10
lines changed

src/platforms/python/guides/bottle/index.mdx

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,50 @@ However the integration with the development version (0.13) doesn't work properl
1515
Install `sentry-sdk` from PyPI with the `bottle` extra:
1616

1717
```bash
18-
pip install --upgrade 'sentry-sdk[bottle]==0.16.2'
18+
pip install --upgrade 'sentry-sdk[bottle]'
1919
```
2020

2121
## Configure
2222

23-
To configure the SDK, initialize it with the integration before your app has been initialized:
23+
If you have the `bottle` package in your dependencies, the Bottle integration will be enabled automatically when you initialize the Sentry SDK.
2424

2525
<SignInNote />
2626

2727
```python
28+
from bottle import Bottle
2829
import sentry_sdk
2930

30-
from bottle import Bottle, run
31-
from sentry_sdk.integrations.bottle import BottleIntegration
32-
3331
sentry_sdk.init(
3432
dsn="___PUBLIC_DSN___",
35-
integrations=[
36-
BottleIntegration(),
37-
],
38-
3933
# Set traces_sample_rate to 1.0 to capture 100%
4034
# of transactions for performance monitoring.
41-
# We recommend adjusting this value in production,
4235
traces_sample_rate=1.0,
4336
)
4437

4538
app = Bottle()
4639
```
4740

41+
## Verify
42+
43+
```python
44+
from bottle import Bottle, run
45+
46+
sentry_sdk.init(...) # same as above
47+
48+
app = Bottle()
49+
50+
@app.route('/')
51+
def hello():
52+
1/0
53+
return "Hello World!"
54+
55+
run(app, host='localhost', port=8000)
56+
```
57+
58+
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.
59+
60+
It takes a couple of moments for the data to appear in [sentry.io](https://sentry.io).
61+
4862
## Behavior
4963

5064
- The Sentry Python SDK will install the Bottle integration for all of your apps. The integration hooks into base Bottle class.
@@ -57,6 +71,26 @@ app = Bottle()
5771

5872
## Options
5973

74+
If you add `BottleIntegration` explicitly to your `sentry_sdk.init()` call you can set options for `BottleIntegration` to change its behavior:
75+
76+
```python
77+
import sentry_sdk
78+
from sentry_sdk.integrations.bottle import BottleIntegration
79+
80+
sentry_sdk.init(
81+
dsn="___PUBLIC_DSN___",
82+
# Set traces_sample_rate to 1.0 to capture 100%
83+
# of transactions for performance monitoring.
84+
traces_sample_rate=1.0,
85+
integrations = [
86+
BottleIntegration(
87+
transaction_style="endpoint",
88+
),
89+
],
90+
)
91+
92+
```
93+
6094
You can pass the following keyword arguments to `BottleIntegration()`:
6195

6296
- `transaction_style`:
@@ -73,3 +107,8 @@ You can pass the following keyword arguments to `BottleIntegration()`:
73107
- `myendpoint` if you set `transaction_style="endpoint"`
74108

75109
The default is `"endpoint"`.
110+
111+
## Supported Versions
112+
113+
- Bottle: 0.12.13+
114+
- Python: 2.7+

0 commit comments

Comments
 (0)