Skip to content

refactor: migrate Python and related guides to the inline product option syntax #13412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/platforms/python/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,25 @@ Configuration should happen as **early as possible** in your application's lifec



```python {"onboardingOptions": {"performance": "8-10", "profiling": "11-14"}}
```python
import sentry_sdk

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
# Add request headers and IP for users,
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
)
```

Expand Down
6 changes: 5 additions & 1 deletion docs/platforms/python/integrations/asgi/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Select which Sentry features you'd like to install in addition to Error Monitori
]}
/>

```python {"onboardingOptions": {"performance": "11-13", "profiling": "14-17"}}
```python
import sentry_sdk
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware

Expand All @@ -43,13 +43,17 @@ sentry_sdk.init(
# Add data like request headers and IP for users, if applicable;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
)

app = SentryAsgiMiddleware(app)
Expand Down
6 changes: 5 additions & 1 deletion docs/platforms/python/integrations/asyncio/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ If you call `sentry_sdk.init()` outside of an `async` function in an async appli
]}
/>

```python {filename:main.py} {"onboardingOptions": {"performance": "10-12", "profiling": "13-16"}}
```python {filename:main.py}
import sentry_sdk
from sentry_sdk.integrations.asyncio import AsyncioIntegration

Expand All @@ -39,13 +39,17 @@ async def main():
# Add data like request headers and IP for users, if applicable;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
integrations=[
AsyncioIntegration(),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Select which Sentry features you'd like to install in addition to Error Monitori
]}
/>

```python {"onboardingOptions": {"performance": "9-11", "profiling": "12-15"}}
```python
import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration

Expand All @@ -53,13 +53,17 @@ sentry_sdk.init(
# Add data like request headers and IP for users, if applicable;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
integrations=[
AwsLambdaIntegration(),
],
Expand Down
6 changes: 5 additions & 1 deletion docs/platforms/python/integrations/beam/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Select which Sentry features you'd like to install in addition to Error Monitori
]}
/>

```python {"onboardingOptions": {"performance": "9-11", "profiling": "12-15"}}
```python
import sentry_sdk
from sentry_sdk.integrations.beam import BeamIntegration

Expand All @@ -33,13 +33,17 @@ sentry_sdk.init(
# Add data like request headers and IP for users, if applicable;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
integrations=[
BeamIntegration(),
],
Expand Down
6 changes: 5 additions & 1 deletion docs/platforms/python/integrations/celery/crons.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Select which Sentry features you'd like to install in addition to Error Monitori
options={["error-monitoring", "performance", "profiling"]}
/>

```python {diff} {filename:tasks.py} {"onboardingOptions": {"performance": "15-17", "profiling": "18-21"}}
```python {diff} {filename:tasks.py}
# tasks.py
from celery import signals

Expand All @@ -65,13 +65,17 @@ def init_sentry(**kwargs):
# Add data like request headers and IP for users, if applicable;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
+ integrations=[
+ CeleryIntegration(
+ monitor_beat_tasks=True
Expand Down
14 changes: 11 additions & 3 deletions docs/platforms/python/integrations/celery/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ In addition to capturing errors, you can use Sentry for [distributed tracing](/c
options={["error-monitoring", "performance", "profiling"]}
/>

```python {filename:tasks.py} {"onboardingOptions": {"performance": "15-17", "profiling": "18-21"}}
```python {filename:tasks.py}
from celery import Celery, signals
import sentry_sdk

Expand All @@ -50,13 +50,17 @@ def init_sentry(**_kwargs):
# Add request headers and IP for users,
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
)

# Task definitions go here
Expand All @@ -73,7 +77,7 @@ The [`celeryd_init`](https://docs.celeryq.dev/en/stable/userguide/signals.html?#
options={["error-monitoring", "performance", "profiling"]}
/>

```python {filename:main.py} {"onboardingOptions": {"performance": "11-13", "profiling": "14-17"}}
```python {filename:main.py}
from tasks import add
import sentry_sdk

Expand All @@ -84,13 +88,17 @@ def main():
# Add data like request headers and IP for users, if applicable;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
)

# Enqueueing a task to be processed by Celery
Expand All @@ -111,7 +119,7 @@ To confirm that your SDK is initialized on worker start, pass `debug=True` to `s

The snippet below includes an intentional `ZeroDivisionError` in the Celery task that will be captured by Sentry. To trigger the error call `debug_sentry.delay()`:

```python {filename:tasks.py} {"onboardingOptions": {"performance": "12-14", "profiling": "15-18"}}
```python {filename:tasks.py}
from celery import Celery, signals
import sentry_sdk

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Select which Sentry features you'd like to install in addition to Error Monitori
]}
/>

```python {"onboardingOptions": {"performance": "9-11", "profiling": "12-15"}}
```python
import sentry_sdk
from sentry_sdk.integrations.cloud_resource_context import CloudResourceContextIntegration

Expand All @@ -39,13 +39,17 @@ sentry_sdk.init(
# Add data like request headers and IP for users, if applicable;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
integrations=[
CloudResourceContextIntegration(),
],
Expand Down
6 changes: 5 additions & 1 deletion docs/platforms/python/integrations/django/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,25 @@ Select which Sentry features you'd like to install in addition to Error Monitori
]}
/>

```python {filename:settings.py} {"onboardingOptions": {"performance": "8-10", "profiling": "11-14"}}
```python {filename:settings.py}
import sentry_sdk

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
# Add data like request headers and IP for users;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
)
```

Expand Down
6 changes: 5 additions & 1 deletion docs/platforms/python/integrations/gcp-functions/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Select which Sentry features you'd like to install in addition to Error Monitori
]}
/>

```python {"onboardingOptions": {"performance": "9-11", "profiling": "12-15"}}
```python
import sentry_sdk
from sentry_sdk.integrations.gcp import GcpIntegration

Expand All @@ -44,13 +44,17 @@ sentry_sdk.init(
# Add data like request headers and IP for users, if applicable;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
integrations=[
GcpIntegration(),
],
Expand Down
12 changes: 10 additions & 2 deletions docs/platforms/python/integrations/grpc/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Select which Sentry features you'd like to install in addition to Error Monitori

### Server

```python {"onboardingOptions": {"performance": "11-13", "profiling": "14-17"}}
```python
import grpc

import sentry_sdk
Expand All @@ -48,13 +48,17 @@ sentry_sdk.init(
# Add data like request headers and IP for users, if applicable;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
integrations=[
GRPCIntegration(),
],
Expand All @@ -72,7 +76,7 @@ server = grpc.aio.server()

### Client

```python {"onboardingOptions": {"performance": "8-10", "profiling": "11-14"}}
```python
import grpc

import sentry_sdk
Expand All @@ -83,13 +87,17 @@ sentry_sdk.init(
# Add data like request headers and IP for users, if applicable;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
integrations=[
GRPCIntegration(),
],
Expand Down
6 changes: 5 additions & 1 deletion docs/platforms/python/integrations/langchain/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,25 @@ Select which Sentry features you'd like to install in addition to Error Monitori
]}
/>

```python {"onboardingOptions": {"performance": "9-11", "profiling": "12-15"}}
```python
import sentry_sdk

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
# Send personally-identifiable information like LLM responses to Sentry;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
# ___PRODUCT_OPTION_START___ performance
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
traces_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ performance
# ___PRODUCT_OPTION_START___ profiling
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# ___PRODUCT_OPTION_END___ profiling
)
```

Expand Down
Loading