-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
docs(python): update integrations for stream mode #18526
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,8 @@ Once you've installed this SDK, you can use the Sentry AI Agents Monitoring, a S | |||||||||
|
|
||||||||||
| Sentry AI Monitoring will automatically collect information about prompts, tools, tokens, and models. Learn more about the [AI Agents Dashboard](/ai/monitoring/agents). | ||||||||||
|
|
||||||||||
| <Include name="python-stream-mode-general-callout.mdx" /> | ||||||||||
|
|
||||||||||
| ## Install | ||||||||||
|
|
||||||||||
| Install `sentry-sdk` from PyPI: | ||||||||||
|
|
@@ -40,6 +42,7 @@ sentry_sdk.init(...) # same as above | |||||||||
| client = Anthropic(api_key="(your Anthropic key)") | ||||||||||
|
|
||||||||||
| def my_llm_stuff(): | ||||||||||
| # or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode | ||||||||||
| with sentry_sdk.start_transaction(name="The result of the AI inference"): | ||||||||||
|
Comment on lines
+45
to
46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't really matter but I think the names should be aligned here
Suggested change
|
||||||||||
| print( | ||||||||||
| client.messages.create( | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,13 +5,16 @@ description: "Learn about using Sentry with arq." | |||||||||
|
|
||||||||||
| The arq integration adds support for the [arq job queue system](https://arq-docs.helpmanual.io/). | ||||||||||
|
|
||||||||||
| <Include name="python-stream-mode-general-callout.mdx" /> | ||||||||||
|
|
||||||||||
| ## Install | ||||||||||
|
|
||||||||||
| Install `sentry-sdk` from PyPI: | ||||||||||
|
|
||||||||||
| ```bash {tabTitle:pip} | ||||||||||
| pip install sentry-sdk | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ```bash {tabTitle:uv} | ||||||||||
| uv add sentry-sdk | ||||||||||
| ``` | ||||||||||
|
|
@@ -36,6 +39,7 @@ async def main(): | |||||||||
| sentry_sdk.init(...) # same as above | ||||||||||
| redis = await create_pool(RedisSettings()) | ||||||||||
|
|
||||||||||
| # or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode | ||||||||||
| with sentry_sdk.start_transaction(name="testing_sentry"): | ||||||||||
|
Comment on lines
+42
to
43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't really matter but I think the names should be aligned here
Suggested change
|
||||||||||
| r = await redis.enqueue_job("add_numbers", 1, 2) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,13 +6,16 @@ description: "Learn about importing the asyncpg integration and how it captures | |||||||||
| The `AsyncPGIntegration` captures queries from | ||||||||||
| [asyncpg](https://github.com/MagicStack/asyncpg), which can be viewed in Sentry's **Performance** page. | ||||||||||
|
|
||||||||||
| <Include name="python-stream-mode-general-callout.mdx" /> | ||||||||||
|
|
||||||||||
| ## Install | ||||||||||
|
|
||||||||||
| Install `sentry-sdk` from PyPI: | ||||||||||
|
|
||||||||||
| ```bash {tabTitle:pip} | ||||||||||
| pip install sentry-sdk | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ```bash {tabTitle:uv} | ||||||||||
| uv add sentry-sdk | ||||||||||
| ``` | ||||||||||
|
|
@@ -31,6 +34,7 @@ import asyncpg | |||||||||
| async def main(): | ||||||||||
| sentry_sdk.init(...) # same as above | ||||||||||
|
|
||||||||||
| # or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode | ||||||||||
| with sentry_sdk.start_transaction(name="testing_sentry"): | ||||||||||
|
Comment on lines
+37
to
38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| conn = await asyncpg.connect(DATABASE_URL) | ||||||||||
| await conn.fetch("SELECT * FROM pg_catalog.pg_tables;") | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,13 +5,16 @@ description: "Learn about using Sentry with Celery." | |||||||||
|
|
||||||||||
| The Celery integration adds support for the [Celery Task Queue System](https://docs.celeryq.dev/). | ||||||||||
|
|
||||||||||
| <Include name="python-stream-mode-general-callout.mdx" /> | ||||||||||
|
|
||||||||||
| ## Install | ||||||||||
|
|
||||||||||
| Install `sentry-sdk` from PyPI: | ||||||||||
|
|
||||||||||
| ```bash {tabTitle:pip} | ||||||||||
| pip install sentry-sdk | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ```bash {tabTitle:uv} | ||||||||||
| uv add sentry-sdk | ||||||||||
| ``` | ||||||||||
|
|
@@ -110,6 +113,7 @@ def main(): | |||||||||
|
|
||||||||||
| # Enqueueing a task to be processed by Celery | ||||||||||
| with sentry_sdk.start_transaction(name="calling-a-celery-task"): | ||||||||||
| # or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode | ||||||||||
|
Comment on lines
115
to
+116
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| result = add.delay(4, 4) | ||||||||||
|
|
||||||||||
| if __name__ == "__main__": | ||||||||||
|
|
@@ -178,7 +182,6 @@ You can pass the following keyword arguments to `CeleryIntegration()`: | |||||||||
| Propagate Sentry tracing information to the Celery task. This makes it possible to link Celery task errors to the function that triggered the task. | ||||||||||
|
|
||||||||||
| If this is set to `False`: | ||||||||||
|
|
||||||||||
| - errors in Celery tasks won't be matched to the triggering function. | ||||||||||
| - your Celery tasks will start a new trace and won't be connected to the trace in the calling function. | ||||||||||
|
|
||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't really matter but I think the names should be aligned here