diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index 5658ee04fd..495bfff75e 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -1,6 +1,5 @@ # Sentry SDK Migration Guide - ## Upgrading to 3.0 Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of what's changed. Looking for a more digestible summary? See the [guide in the docs](https://docs.sentry.io/platforms/python/migration/2.x-to-3.x) with the most common migration patterns. @@ -19,6 +18,7 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh - `sentry_sdk.continue_trace` no longer returns a `Transaction` and is now a context manager. - Redis integration: In Redis pipeline spans there is no `span["data"]["redis.commands"]` that contains a dict `{"count": 3, "first_ten": ["cmd1", "cmd2", ...]}` but instead `span["data"]["redis.commands.count"]` (containing `3`) and `span["data"]["redis.commands.first_ten"]` (containing `["cmd1", "cmd2", ...]`). - clickhouse-driver integration: The query is now available under the `db.query.text` span attribute (only if `send_default_pii` is `True`). +- `sentry_sdk.init` now returns `None` instead of a context manager. ### Removed @@ -40,7 +40,6 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh - `continue_from_headers`, `continue_from_environ` and `from_traceparent` have been removed, please use top-level API `sentry_sdk.continue_trace` instead. - `PropagationContext` constructor no longer takes a `dynamic_sampling_context` but takes a `baggage` object instead. - ### Deprecated - `sentry_sdk.start_transaction` is deprecated. Use `sentry_sdk.start_span` instead. diff --git a/sentry_sdk/_init_implementation.py b/sentry_sdk/_init_implementation.py index 256a69ee83..dc235af243 100644 --- a/sentry_sdk/_init_implementation.py +++ b/sentry_sdk/_init_implementation.py @@ -3,27 +3,11 @@ import sentry_sdk if TYPE_CHECKING: - from typing import Any, ContextManager, Optional + from typing import Any, Optional import sentry_sdk.consts -class _InitGuard: - def __init__(self, client): - # type: (sentry_sdk.Client) -> None - self._client = client - - def __enter__(self): - # type: () -> _InitGuard - return self - - def __exit__(self, exc_type, exc_value, tb): - # type: (Any, Any, Any) -> None - c = self._client - if c is not None: - c.close() - - def _check_python_deprecations(): # type: () -> None # Since we're likely to deprecate Python versions in the future, I'm keeping @@ -33,7 +17,7 @@ def _check_python_deprecations(): def _init(*args, **kwargs): - # type: (*Optional[str], **Any) -> ContextManager[Any] + # type: (*Optional[str], **Any) -> None """Initializes the SDK and optionally integrations. This takes the same arguments as the client constructor. @@ -41,8 +25,6 @@ def _init(*args, **kwargs): client = sentry_sdk.Client(*args, **kwargs) sentry_sdk.get_global_scope().set_client(client) _check_python_deprecations() - rv = _InitGuard(client) - return rv if TYPE_CHECKING: @@ -52,7 +34,7 @@ def _init(*args, **kwargs): # Use `ClientConstructor` to define the argument types of `init` and # `ContextManager[Any]` to tell static analyzers about the return type. - class init(sentry_sdk.consts.ClientConstructor, _InitGuard): # noqa: N801 + class init(sentry_sdk.consts.ClientConstructor): # noqa: N801 pass else: