Skip to content

feat(transport): Remove HttpTransport hub_cls attribute #3412

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions sentry_sdk/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import urllib3
import certifi

import sentry_sdk
from sentry_sdk.consts import EndpointType
from sentry_sdk.utils import Dsn, logger, capture_internal_exceptions
from sentry_sdk.worker import BackgroundWorker
Expand Down Expand Up @@ -231,9 +230,6 @@ def __init__(
proxy_headers=options["proxy_headers"],
)

# Backwards compatibility for deprecated `self.hub_class` attribute
self._hub_cls = sentry_sdk.Hub

def record_lost_event(
self,
reason, # type: str
Expand Down Expand Up @@ -604,30 +600,6 @@ def kill(self):
logger.debug("Killing HTTP transport")
self._worker.kill()

@staticmethod
def _warn_hub_cls():
# type: () -> None
"""Convenience method to warn users about the deprecation of the `hub_cls` attribute."""
warnings.warn(
"The `hub_cls` attribute is deprecated and will be removed in a future release.",
DeprecationWarning,
stacklevel=3,
)

@property
def hub_cls(self):
# type: () -> type[sentry_sdk.Hub]
"""DEPRECATED: This attribute is deprecated and will be removed in a future release."""
HttpTransport._warn_hub_cls()
return self._hub_cls

@hub_cls.setter
def hub_cls(self, value):
# type: (type[sentry_sdk.Hub]) -> None
"""DEPRECATED: This attribute is deprecated and will be removed in a future release."""
HttpTransport._warn_hub_cls()
self._hub_cls = value


class _FunctionTransport(Transport):
"""
Expand Down
20 changes: 0 additions & 20 deletions tests/test_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
capture_message,
isolation_scope,
get_isolation_scope,
Hub,
)
from sentry_sdk.envelope import Envelope, Item, parse_json
from sentry_sdk.transport import (
KEEP_ALIVE_SOCKET_OPTIONS,
_parse_rate_limits,
HttpTransport,
)
from sentry_sdk.integrations.logging import LoggingIntegration, ignore_logger

Expand Down Expand Up @@ -649,24 +647,6 @@ def test_metric_bucket_limits_with_all_namespaces(
]


def test_hub_cls_backwards_compat():
class TestCustomHubClass(Hub):
pass

transport = HttpTransport(
defaultdict(lambda: None, {"dsn": "https://[email protected]/123"})
)

with pytest.deprecated_call():
assert transport.hub_cls is Hub

with pytest.deprecated_call():
transport.hub_cls = TestCustomHubClass

with pytest.deprecated_call():
assert transport.hub_cls is TestCustomHubClass


@pytest.mark.parametrize("quantity", (1, 2, 10))
def test_record_lost_event_quantity(capturing_server, make_client, quantity):
client = make_client()
Expand Down
Loading