Next Python SDK major - #5005
sentrivana wants to merge 251 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5005 +/- ##
===========================================
+ Coverage 70.55% 83.76% +13.21%
===========================================
Files 180 180
Lines 18077 18080 +3
Branches 3008 3009 +1
===========================================
+ Hits 12754 15145 +2391
+ Misses 4432 1943 -2489
- Partials 891 992 +101
|
Codecov Results 📊✅ 66062 passed | ❌ 1 failed | ⏭️ 2999 skipped | Total: 69062 | Pass Rate: 95.66% | Execution Time: 191m 10s 📊 Comparison with Base Branch
➕ New Tests (1)View new tests
❌ Failed Tests
|
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛Anthropic
Documentation 📚
Internal Changes 🔧
Other
🤖 This preview updates automatically when you update the PR. |
Add `UnraisablehookIntegration` to the default integrations list.
Stop raising exceptions `from None` in the ASGI and asyncio integrations. Closes #5624
Remove everything hub related, including all sorts of compatibility shims around hubs/scopes. Also remove deprecated session methods. `configure_scope` and `push_scope` removal coming in a future PR. #### Issues Closes #5001
The integration requires additional configuration which should be intentional on the user's part. #### Issues Closes #4993
- Remove everything in `integrations/opentelemetry` (`SentrySpanProcessor`, `SentryPropagator`, etc.) - Remove associated test files and CI config - Move old propagator functions and consts that we were using in `OTLPIntegration` to the OTLP propagator directly - Remove `instrumenter` Note: `NoOpSpan` was not removed because it makes mypy blow up. Not worth the effort as we'll anyway get rid of it when dropping transaction based tracing. #### Issues Closes #6932
### Description The API is deprecated and slated for removal in 3.0. #### Issues Closes #5019 #### Reminders - Please add tests to validate your changes, and lint your code using `uv run ruff`. - Add GH Issue ID _&_ Linear ID (if applicable) - PR title should use [conventional commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type) style (`feat:`, `fix:`, `ref:`, `meta:`) - For external contributors: [CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md), [Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord community](https://discord.gg/Ww9hbqr)
### Description Remove the deprecated API. #### Issues Closes #5018
### Description Most of the entries in our extras list serve as a way to communicate/enforce the lower boundary of the respective framework that we support. This creates a parallel system to the version checks we already have in each integration. Some extras, however, define extra dependencies or specific extras that are required for an integration to work correctly (e.g. the Flask integration needs `blinker` to work properly). In that case, keep the extra. #### Issues Closes #6259
### Description See the original potel PR linked in the ticket for more context. #### Issues Closes https://linear.app/getsentry/issue/PY-1938/remove-spotlight-django-integration Closes #5014
Remove tests testing implementation details of the old tracing system. Adapt tests that still make sense in span streaming. Remove tests that already have a streaming version.
These were all duplicated. Left the span streaming versions only.
- add `trace_lifecycle="stream"` to all tests that set a `traces_sample_rate` or `traces_sampler` - remove more duplicated tests - switch all tracing API in tests to span streaming
- Remove `Span`s from type annotations in integrations - Remove helpers like `set_on_span`, `set_span_data_attribute` Taking at least some stuff out of #7468 to make it more reviewable
This time from tracing_utils.
- remove transaction events from tests (replace with other event types if necessary) - remove transaction helpers from conftest - remove tests that assert on us emitting warnings if using incompatible api (streaming/non-streaming) - remove tests that test `_experiments`/top-level option precedence for span streaming options (options not available in `_experiments` anymore) - some args reformatting
…n` with `gen_ai.response.time_to_first_chunk` (#7472)
Replace all uses of `gen_ai.usage.input_tokens.cached` with `gen_ai.usage.cache_read.input_tokens`, all uses of `gen_ai.usage.input_tokens.cache_write` with `gen_ai.usage.cache_creation.input_tokens`, and all uses of `gen_ai.usage.output_tokens.reasoning` with `gen_ai.usage.reasoning.output_tokens`.
- Remove the `Span` and `Transaction` classes and associated types - Remove transaction/old span support from transport, client, scope - Rewire top-level API to `sentry_sdk.traces.*` - Remove old span counting/reporting (`dropped_spans` etc.) - Remove `has_span_streaming_enabled` - ...and more It's a big diff but no logic changes, just removing anything old span related. Closes https://linear.app/getsentry/issue/PY-2654/rewire-top-level-tracing-api-to-span-streaming Closes https://linear.app/getsentry/issue/PY-2655/remove-legacy-tracing Closes https://linear.app/getsentry/issue/PY-2653/remove-has-span-streaming-enabled-branches-from-core
This original message count is never set since truncation for GenAI spans was removed.
Remove last mention of `set_data` (it's commented out, but still). Closes https://linear.app/getsentry/issue/PY-1946/deprecatedrop-set-data
… present (#7493) Use a boolean scope member to suppress chat generation spans from client libraries that are inside a chat generation span from an agent framework. Add the `traces._AgentFrameworkChatGenerationContext` wrapper to ensure the scope member is reset when the agent framework span exits. Remove logic that disables client library integrations when an agent library is active. Delete the `integration_deactivation` tox environment that ran the corresponding tests. Use the context manager in all agent frameworks that create chat generation spans (`langchain`, `pydantic-ai`, and `openai-agents`). Add early returns for chat generation spans in the `openai`, `anthropic`, and `google-genai` client libraries to prevent duplicate generation spans. Remove embedding patches from the `langchain` integration. These must now be provided by client libraries like `openai`, `anthropic`, etc. Closes #5515
- remove `scope.transaction` (`set_transaction_name` remains for now; changed all direct uses of `scope.transaction =` to use `set_transaction_name` instead) - remove more interop utils (`_serialized_v1_attribute_to_serialized_v2_attribute` etc.) - remove event processor-based transaction name setting (superseded by `set_transaction_name` directly in patches) - ...
…spans (#7512) Remove the response model from Invoke Agent spans because it is ambiguous for an agent that can call different models in the course of its execution.
…t spans (#7513) Remove the response model from Invoke Agent spans because it is ambiguous for an agent that can call different models in the course of its execution.
Remove token attributes from Invoke Agent spans because it is ambiguous whether they include usage from tool calls.
Remove token attributes from Invoke Agent spans because it is ambiguous whether they include usage from tool calls.
Also: remove remaining things from tracing.py and delete the file. Closes https://linear.app/getsentry/issue/PY-2771/switch-transactionsource-to-segmentnamesource-everywhere
We're preparing our next major on this branch.
The project is tracked in Linear. If you don't have access, we'll try to tag issues belonging to the project with the
SDK3.0 label on GitHub so that you can follow along.Notable changes
Context
You might have read this announcement about us discontinuing work on a 3.0. This is referring to the work done on the
potel-basebranch, which included two types of changes: a huge refactor of our tracing code on the one hand, and various unrelated changes, improvements and fixes on the other. We're dropping the huge refactor part, and only porting the rest, to a new branch and eventually a new 3.0 release.