Skip to content

Conversation

srothh
Copy link
Member

@srothh srothh commented Sep 1, 2025

Update the migration guide for 3.0 to include information on the async transport and context manager

@srothh srothh changed the base branch from master to potel-base September 1, 2025 13:40
Copy link

codecov bot commented Sep 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.61%. Comparing base (f1850ce) to head (752db32).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@              Coverage Diff               @@
##           potel-base    #4732      +/-   ##
==============================================
- Coverage       84.61%   84.61%   -0.01%     
==============================================
  Files             158      158              
  Lines           16162    16162              
  Branches         2575     2575              
==============================================
- Hits            13676    13675       -1     
  Misses           1693     1693              
- Partials          793      794       +1     

see 1 file with indirect coverage changes

@srothh srothh marked this pull request as ready for review September 2, 2025 06:48
@srothh srothh requested a review from a team as a code owner September 2, 2025 06:48
Comment on lines 11 to 13
- Added a new experimental async transport using the [httpcore](https://pypi.org/project/httpcore/) library. Requires the [httpcore[asyncio]](https://www.encode.io/httpcore/async/) extension. The async transport makes Sentry network I/O non-blocking in async programs. The async transport can only be used when an event loop is running, and additionally requires the [asyncio](https://docs.sentry.io/platforms/python/integrations/asyncio/) integration. Can be enabled by passing ``transport_async=true`` in the experiments dict in ``sentry.init()``.
- Added an asynchronous context manager for spans. This can be used to remove unnessecary nesting for span creation in async programs.
- Added `flush_async()` as a top level API. This has to be used when flushing the async transport. `flush_async` is a coroutine and can be awaited if blocking behaviour is desired.
Copy link

Choose a reason for hiding this comment

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

Potential bug: The migration guide documents a new flush_async() function and transport_async option, but they are not implemented, causing an AttributeError when called.
  • Description: The migration guide introduces documentation for new asynchronous transport functionality, including a top-level flush_async() function, an AsyncHttpTransport class, and a transport_async configuration option. However, none of these features are implemented in the codebase. Users following the guide and attempting to call sentry_sdk.flush_async() will encounter an AttributeError, causing their application to crash. This discrepancy between documentation and the actual API guarantees a runtime failure for users trying to adopt the documented async features.

  • Suggested fix: Remove the section from the migration guide that describes the flush_async() function, the transport_async configuration option, and the AsyncHttpTransport class, as these features are not implemented in the current codebase. Alternatively, implement the documented functionality.
    severity: 0.82, confidence: 0.98

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Seer seems to have a point here unless I'm grepping incorrectly

Copy link
Member Author

Choose a reason for hiding this comment

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

I created the migration branch before adding this function to the API, I can merge potel base back in then flush_async should be here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should be here now

Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

Thanks for adding! Left some formatting suggestions and a question regarding the seer comment

Comment on lines 11 to 13
- Added a new experimental async transport using the [httpcore](https://pypi.org/project/httpcore/) library. Requires the [httpcore[asyncio]](https://www.encode.io/httpcore/async/) extension. The async transport makes Sentry network I/O non-blocking in async programs. The async transport can only be used when an event loop is running, and additionally requires the [asyncio](https://docs.sentry.io/platforms/python/integrations/asyncio/) integration. Can be enabled by passing ``transport_async=true`` in the experiments dict in ``sentry.init()``.
- Added an asynchronous context manager for spans. This can be used to remove unnessecary nesting for span creation in async programs.
- Added `flush_async()` as a top level API. This has to be used when flushing the async transport. `flush_async` is a coroutine and can be awaited if blocking behaviour is desired.
Copy link
Contributor

Choose a reason for hiding this comment

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

Seer seems to have a point here unless I'm grepping incorrectly

@@ -8,7 +8,9 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh

- Added `add_attachment()` as a top level API, so you can do now: `sentry_sdk.add_attachment(...)` (up until now it was only available on the `Scope`)
- Added a new SDK option `exclude_span_origins`. Spans with an `origin` from `exclude_span_origins` won't be created. This can be used for example in dual OpenTelemetry/Sentry setups to filter out spans from specific Sentry instrumentations. Note that using `exclude_span_origins` might potentially lead to surprising results: if, for example, a root span is excluded based on `origin`, all of its children will become root spans, unless they were started with `only_as_child_span=True`.

- Added a new experimental async transport using the [httpcore](https://pypi.org/project/httpcore/) library. Requires the [httpcore[asyncio]](https://www.encode.io/httpcore/async/) extension. The async transport makes Sentry network I/O non-blocking in async programs. The async transport can only be used when an event loop is running, and additionally requires the [asyncio](https://docs.sentry.io/platforms/python/integrations/asyncio/) integration. Can be enabled by passing ``transport_async=true`` in the experiments dict in ``sentry.init()``.
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be worth having a code snippet?

Suggested change
- Added a new experimental async transport using the [httpcore](https://pypi.org/project/httpcore/) library. Requires the [httpcore[asyncio]](https://www.encode.io/httpcore/async/) extension. The async transport makes Sentry network I/O non-blocking in async programs. The async transport can only be used when an event loop is running, and additionally requires the [asyncio](https://docs.sentry.io/platforms/python/integrations/asyncio/) integration. Can be enabled by passing ``transport_async=true`` in the experiments dict in ``sentry.init()``.
- Added a new experimental async transport using the [httpcore](https://pypi.org/project/httpcore/) library. Requires the [httpcore[asyncio]](https://www.encode.io/httpcore/async/) extension. The async transport makes Sentry network I/O non-blocking in async programs. The async transport can only be used when an event loop is running. Try it out by initializing Sentry with:
```python
import sentry_sdk
from sentry_sdk.integrations.asyncio import AsyncioIntegration
sentry_sdk.init(
_experiments={
"transport_async": True,
},
integrations=[
sentry_sdk.AsyncIO(),
]
)
```.

Copy link
Member Author

Choose a reason for hiding this comment

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

added, thanks for the suggestion!

srothh and others added 2 commits September 2, 2025 10:57
…details

Expanded the migration guide with details on the new experimental async transport feature and provided usage examples.
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

👍🏻

@srothh srothh merged commit ebd77f2 into potel-base Sep 2, 2025
125 of 126 checks passed
@srothh srothh deleted the srothh/update-migration-guide branch September 2, 2025 14:44
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.

3 participants