Skip to content
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

SDK 2.0 #2670

Closed
wants to merge 52 commits into from
Closed

SDK 2.0 #2670

wants to merge 52 commits into from

Conversation

sentrivana
Copy link
Contributor

Once the SDK 2.0 branch is ready, merge it into master.

Closes #2662


General Notes

Thank you for contributing to sentry-python!

Please add tests to validate your changes, and lint your code using tox -e linters.

Running the test suite on your PR might require maintainer approval. Some tests (AWS Lambda) additionally require a maintainer to add a special label to run and will fail if the label is not present.

For maintainers

Sensitive test suites require maintainer review to ensure that tests do not compromise our secrets. This review must be repeated after any code revisions.

Before running sensitive test suites, please carefully check the PR. Then, apply the Trigger: tests using secrets label. The label will be removed after any code changes to enforce our policy requiring maintainers to review all code revisions before running sensitive tests.

sentrivana and others added 17 commits December 13, 2023 16:45
- remove special treatment for Python 2.7 from CI YAML generating
- remove Python 2.7, 3.5 test environments from `tox.ini`
UTF-8 is the default in Python 3.
Remove Python<=3.5 compatibility utils from `_compat.py`.

---------

Co-authored-by: Daniel Szoke <[email protected]>
- Remove tracing_utils_py2.py, move the contents of tracing_utils_py3.py to tracing_utils. Some code reorganization was needed to avoid circular imports.
- Move the contents of test_decorator_sync.py and test_decorator_async_py3.py to a new file, test_decorator.py, and remove the original files.
- remove py<=3.5 specific imports
- remove test markers for skipping/xfailing tests on py<=3.5
sentrivana and others added 11 commits January 24, 2024 14:05
* remove deprecated client options
* remove .install()
* remove new_span
## Summary

This change removes all usages of the deprecated `store` endpoint from the Python SDK. From now on, events that were previously sent to the `store` endpoint will now be sent as envelopes to the `envelope` endpoint. 


## Breaking API changes

  - `sentry_sdk.transport.Transport` is now an abstract base class, and therefore, it cannot be instantiated directly. Subclasses must implement the `capture_envelope` method.
  - `sentry_sdk.utils.Auth.store_api_url` has been removed.
  - `sentry_sdk.utils.Auth.get_api_url`'s now accepts a `sentry_sdk.consts.EndpointType` enum instead of a string as its only parameter. Supplying this parameter is currently unnecessary, since the parameter's default value is the only possible `sentry_sdk.consts.EndpointType` value.


## Backwards-compatible API changes
  - `sentry_sdk.transport.Transport.capture_event` has been deprecated. Please use `sentry_sdk.transport.Transport.capture_envelope`, instead.
  - Passing a function to `sentry_sdk.init`'s `transport` keyword argument has been deprecated. If you wish to provide a custom transport, please pass a `sentry_sdk.transport.Transport` instance or a subclass.


## Other changes
  - `sentry_sdk.transport.HttpTransport._send_event` has been removed, and uses of this method have been removed from the codebase, including from tests.
  - Cleaned up some transport-related test code

_________________________


* Remove store endpoint

* Fix linter error

* Add stacklevel to warn call

* Remove `store_api_url` test, update `get_api_url` test

* Fix mypy

* Correct import

* Use `Enum` instead of `StrEnum`

* Update `envelope.py`

* Remove `Envelope.events` calls

* Fix `capture_events_forksafe`

* Hopefully fix circular import

* Manually set TestTransport

* Fix circular import

* Revert "Fix circular import"

This reverts commit e681bdb.

* Revert "Hopefully fix circular import"

This reverts commit 7105849.

* Move EndpointType to top of file

* Fix AWS tests

* Remove TODO comment

* Undo ABC change
I will make a separate PR for this

* Update

* Rename envelope_item to envelope_items

* Remove unneeded import statement

* Updated migration guide

* Put back `has_tracing_enabled` check

* Remove test for replay context

* Update MIGRATION_GUIDE.md

* Auto-enable more integrations (#2671)

* Remove deprecated code (#2666)

* remove deprecated client options
* remove .install()
* remove new_span


Fixes GH-1957

---------

Co-authored-by: Ivana Kellyerova <[email protected]>
Pyramid integration update
sentrivana and others added 24 commits February 7, 2024 15:54
This refactors the SDK to move away from the Hub and have all the functionality in the Scope. Introducing different types of scopes. This aligns the SDK with how Opentelementry (OTel) handles data bringing us closer to be 100% OTel compatible.

This change was discussed in this RFC: 
getsentry/rfcs#122

There is also a small FAQ: 
https://gist.github.com/mitsuhiko/1bc78d04ea7d08e5b50d27e42676db80

And a Miro board showing how the new scopes manage data: 
https://miro.com/app/board/uXjVNtPiOfI=/?share_link_id=216270218892

### This RP contains
- Introduction of global, isolation, and current scope
- Deprecation of the Hub
- All existing Hub based API still works and is still used by most of our integrations. Under the hood the new Scopes are used.
- (this PR now includes all the changes made in the [first PR](#2609) introducing the new API)

### Breaking changes
- The Pyramid integration will not capture errors that might happen in `authenticated_userid()` in a custom `AuthenticationPolicy` class.
- The parameter `propagate_hub` in `ThreadingIntegration()` was deprecated and renamed to `propagate_scope`.
We have some classes in the SDK that essentially function as abstract classes, since they have some methods that raise NotImplementedError when called, since they are intended to be overriden by a subclass. Now that all supported Python versions support abstract base classes (ABCs), we should refactor these classes to be ABCs. Making this change will explicitly indicate which methods need to be overridden by a subclass.

Changing a public class into an ABC is a breaking change, since instantiating the class, or any subclass that hasn't overridden all abstract methods, will raise an error. Therefore, I have added this (draft) PR to the SDK 2.0 milestone.

* Convert `Transport` class into an ABC

* ABC metrics

* ABC scheduler

* ABC integration

* RequestExtractor comment

* Deprecate `stop_profiling` and stop calling it

This change is required because otherwise, the linter complains about the `stop_profiling` being an empty concrete method in an abstract class.

* Actually, let's remove `stop_profiling`

* Add ABCs to migration guide

* fix mypy

* Make docstring more relevant to users

* `ensure_running` no longer abstract

* Fix mypy
@sentrivana
Copy link
Contributor Author

Will reopen when the time comes 🥁

@sentrivana sentrivana closed this Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SDK 2.0
3 participants