Skip to content

docs(python): update integrations for stream mode#18526

Open
inventarSarah wants to merge 3 commits into
masterfrom
smi/span-first/python-integrations
Open

docs(python): update integrations for stream mode#18526
inventarSarah wants to merge 3 commits into
masterfrom
smi/span-first/python-integrations

Conversation

@inventarSarah

@inventarSarah inventarSarah commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

DESCRIBE YOUR PR

This PR contains the updated integration docs for stream mode.

what I did:

  • added a callout (include) at the top about stream mode
  • added a callout (include) under the Options heading
  • added an inline comment when start_transaction is used

I decided to add callouts rather than make direct edits to each integration file.
I still need to update the integration files to match our new quick start guide format -> could update the stream mode docs then too

Important

Broken links: I added links to the New Spans guide on these pages, but since this guide does not exist in this branch, we get a linting error.
Should only be merged after #18456

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

LEGAL BOILERPLATE

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

EXTRA RESOURCES

@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sentry-docs Ready Ready Preview, Comment Jul 2, 2026 8:15pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
develop-docs Ignored Ignored Preview Jul 2, 2026 8:15pm

Request Review

@inventarSarah inventarSarah force-pushed the smi/span-first/python-integrations branch from b09e983 to 8e5d8e1 Compare June 24, 2026 11:49
@inventarSarah inventarSarah marked this pull request as ready for review June 24, 2026 11:50

@alexander-alderman-webb alexander-alderman-webb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks looks good! A few more occurrences of diverging names that I didn't call out

Comment on lines 45 to 46
# 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"):

Copy link
Copy Markdown
Contributor

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

Suggested change
# 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"):
# or sentry_sdk.traces.start_span(name="The result of the AI inference", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="The result of the AI inference"):

Comment on lines 70 to 71
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):

Copy link
Copy Markdown
Contributor

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

Suggested change
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):
# or sentry_sdk.traces.start_span(name="testing_sentry", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):

Comment on lines 42 to 43
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):

Copy link
Copy Markdown
Contributor

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

Suggested change
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):
# or sentry_sdk.traces.start_span(name="testing_sentry", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):

Comment on lines 37 to 38
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):
# or sentry_sdk.traces.start_span(name="testing_sentry", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):

Comment on lines +115 to +116
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
with sentry_sdk.start_transaction(name="calling-a-celery-task"):
# or sentry_sdk.traces.start_span(name="calling-a-celery-task", parent_span=None) in stream mode

Comment on lines 63 to 64
# 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"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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"):
# or sentry_sdk.traces.start_span(name="The result of the AI inference", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="The result of the AI inference"):

Comment on lines 147 to 148
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(op="function", name="testing_sentry"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(op="function", name="testing_sentry"):
# or sentry_sdk.traces.start_span(name="testing_sentry", parent_span=None) in stream mode
with sentry_sdk.start_transaction(op="function", name="testing_sentry"):

Comment on lines 41 to 42
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):
# or sentry_sdk.traces.start_span(name="testing_sentry", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):

Comment on lines 70 to 71
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):
# or sentry_sdk.traces.start_span(name="testing_sentry", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):

Comment on lines 182 to 183
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):
# or sentry_sdk.traces.start_span(name="testing_sentry", parent_span=None) in stream mode
with sentry_sdk.start_transaction(name="testing_sentry"):

def divide(a, b):
return a/b

# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the other naming consistency comments that Alex has left elsewhere

Suggested change
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
# or sentry_sdk.traces.start_span(name="ray-test", parent_span=None) in stream mode

sentry_sdk.init(...) # same as above
r = redis.Redis(host='localhost', port=6379, decode_responses=True)

# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
# or sentry_sdk.traces.start_span(name="testing_sentry", parent_span=None) in stream mode

sentry_sdk.init(...) # same as above
rc = RedisCluster(host='localhost', port=16379)

# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
# or sentry_sdk.traces.start_span(name="testing_sentry", parent_span=None) in stream mode

sentry_sdk.init(...) # same as above
r = redis.Redis(host='localhost', port=6379)

# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# or sentry_sdk.traces.start_span(name="your_span_name", parent_span=None) in stream mode
# or sentry_sdk.traces.start_span(name="testing_sentry", parent_span=None) in stream mode

@sentrivana sentrivana left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm! Agree with the others that it'd be nice to keep the span names consistent though.

… review suggestions

- Resolve merge conflicts in 8 files (asgi, aws-lambda, grpc, ray, rq, sanic, socket, wsgi)
  keeping master's updated profiling URL (/product/profiling/)
- Apply reviewer suggestions: align stream mode span names with start_transaction names
  across anthropic, aiomysql, arq, asyncpg, celery, google-genai, grpc,
  sqlalchemy, socket, rq, ray, and redis integrations
client = Anthropic(api_key="(your Anthropic key)")

def my_llm_stuff():
# or sentry_sdk.traces.start_span(name="The result of the AI inference", parent_span=None) in stream mode

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The documentation incorrectly references sentry_sdk.traces.start_span() instead of the correct public API sentry_sdk.start_span(), which will cause an AttributeError for users.
Severity: HIGH

Suggested Fix

Replace all occurrences of sentry_sdk.traces.start_span() in the documentation comments with the correct API call, sentry_sdk.start_span(). The public API for creating spans is the same regardless of whether stream mode is enabled.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: docs/platforms/python/integrations/anthropic/index.mdx#L45

Potential issue: The documentation comments in several Python integration files
incorrectly suggest using `sentry_sdk.traces.start_span()` to create a span in stream
mode. This is not a valid public API. The correct function is `sentry_sdk.start_span()`.
Users who copy this example code and enable stream mode will encounter an
`AttributeError` when their code attempts to call the non-existent function, causing
their application to fail. This incorrect guidance is present in multiple locations,
affecting integrations like Anthropic, Celery, RQ, gRPC, Ray, and OpenAI.

Also affects:

  • docs/platforms/python/integrations/celery/index.mdx:116
  • docs/platforms/python/integrations/rq/index.mdx:182~183
  • docs/platforms/python/integrations/grpc/index.mdx:147~148
  • docs/platforms/python/integrations/ray/index.mdx:93
  • docs/platforms/python/integrations/openai/index.mdx:53

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants