Cleanup imports to always use the top level api.#93307
Merged
antonpirker merged 4 commits intomasterfrom Jun 11, 2025
Merged
Conversation
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #93307 +/- ##
==========================================
- Coverage 88.00% 88.00% -0.01%
==========================================
Files 10267 10267
Lines 592054 592059 +5
Branches 22996 22996
==========================================
+ Hits 521026 521027 +1
- Misses 70597 70601 +4
Partials 431 431 |
sentrivana
approved these changes
Jun 11, 2025
sl0thentr0py
approved these changes
Jun 11, 2025
Contributor
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
vishnupsatish
pushed a commit
that referenced
this pull request
Jun 12, 2025
We want every user to always use the top level API provided by the SDK. This does not change any behavior it just makes sure that users do not use classes/APIs that are not strictly public. Also of note: If you see `sentry_sdk.capture_exception()` you immediately know that it is from the Sentry SDk. If you see `capture_exception()` it could come from some other place that does god knows what.
andrewshie-sentry
pushed a commit
that referenced
this pull request
Jun 19, 2025
We want every user to always use the top level API provided by the SDK. This does not change any behavior it just makes sure that users do not use classes/APIs that are not strictly public. Also of note: If you see `sentry_sdk.capture_exception()` you immediately know that it is from the Sentry SDk. If you see `capture_exception()` it could come from some other place that does god knows what.
sl0thentr0py
added a commit
that referenced
this pull request
Jul 2, 2025
Update the codebase so it works with `Sentry Python SDK 3.0.0 alpha`. Sentry SDK 3.0.0 has some backwards incompatibilities and uses Opentelementry under the hood to create spans. ### What this PR does: - replace `sentry_sdk.start_transaction()` with `sentry_sdk.start_span()` - replace `span.set_data()` with `span.set_attribute()` - replace `scope.transaction` with `scope.root_span` - replace `Span.containing_transaction` with `Span.root_span` - replace `custom_sampling_context` with `attributes` parameter - replace `sentry_sdk.scope.get_*_scope()` with `sentry_sdk.get_*_scope()` - replace one `scope.add_attachment()` with `sentry_sdk.add_attachment()` - change one `continue_trace()` to the new context manager. - update `traces_sampler` to use new `sampling_context` format - added a few tests See also the migration guide: https://docs.sentry.io/platforms/python/migration/2.x-to-3.x --- ### Related, but split out into separate PRs: - make sure `traces_sampler` works the same as before (check for `sample_rate`): #93011 - make **all** `get_isolation_scope` calls use the top-level API. Currently, some calls where we `from sentry_sdk import Scope` then call `Scope.get_isolation_scope` still need to be converted to the top-level API: #93307 - check `event["measurements"]` places if those can be removed (because SDK does not support measurements anymore): #92718 - change set_span_data() to set_span_attribute() but check for value NOT be a dict: #92946 - replace `with sentry_sdk.init(dsn=...)` with `with sentry_sdk.new_scope() as scope: scope.set_client(sentry_sdk.Client(dsn=...))` in `src/sentry/runner/main.py`: #92944 - remove `propagate_hub=True` from `ThreadingIntegration`: #93016 - remove minimetrics from the sentry codebase, because the metrics product was never released: #93595 - https://github.com/getsentry/getsentry/pull/17553 - getsentry/devenv#194 - getsentry/devservices#277 - getsentry/pytest-sentry#39 - getsentry/sentry-docs#13939 --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com> Co-authored-by: Daniel Szoke <daniel.szoke@sentry.io> Co-authored-by: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com> Co-authored-by: Ivana Kellyer <ivana.kellyerova@sentry.io> Co-authored-by: Neel Shah <neel.shah@sentry.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We want every user to always use the top level API provided by the SDK. This does not change any behavior it just makes sure that users do not use classes/APIs that are not strictly public.
Also of note: If you see
sentry_sdk.capture_exception()you immediately know that it is from the Sentry SDk. If you seecapture_exception()it could come from some other place that does god knows what.