12
12
import urllib3
13
13
import certifi
14
14
15
+ import sentry_sdk
15
16
from sentry_sdk .consts import EndpointType
16
17
from sentry_sdk .utils import Dsn , logger , capture_internal_exceptions
17
18
from sentry_sdk .worker import BackgroundWorker
37
38
38
39
DataCategory = Optional [str ]
39
40
40
-
41
41
KEEP_ALIVE_SOCKET_OPTIONS = []
42
42
for option in [
43
43
(socket .SOL_SOCKET , lambda : getattr (socket , "SO_KEEPALIVE" ), 1 ), # noqa: B009
@@ -218,9 +218,8 @@ def __init__(
218
218
proxy_headers = options ["proxy_headers" ],
219
219
)
220
220
221
- from sentry_sdk import Hub
222
-
223
- self .hub_cls = Hub
221
+ # Backwards compatibility for deprecated `self.hub_class` attribute
222
+ self ._hub_cls = sentry_sdk .Hub
224
223
225
224
def record_lost_event (
226
225
self ,
@@ -548,14 +547,11 @@ def capture_envelope(
548
547
self , envelope # type: Envelope
549
548
):
550
549
# type: (...) -> None
551
- hub = self .hub_cls .current
552
-
553
550
def send_envelope_wrapper ():
554
551
# type: () -> None
555
- with hub :
556
- with capture_internal_exceptions ():
557
- self ._send_envelope (envelope )
558
- self ._flush_client_reports ()
552
+ with capture_internal_exceptions ():
553
+ self ._send_envelope (envelope )
554
+ self ._flush_client_reports ()
559
555
560
556
if not self ._worker .submit (send_envelope_wrapper ):
561
557
self .on_dropped_event ("full_queue" )
@@ -579,6 +575,30 @@ def kill(self):
579
575
logger .debug ("Killing HTTP transport" )
580
576
self ._worker .kill ()
581
577
578
+ @staticmethod
579
+ def _warn_hub_cls ():
580
+ # type: () -> None
581
+ """Convenience method to warn users about the deprecation of the `hub_cls` attribute."""
582
+ warnings .warn (
583
+ "The `hub_cls` attribute is deprecated and will be removed in a future release." ,
584
+ DeprecationWarning ,
585
+ stacklevel = 3 ,
586
+ )
587
+
588
+ @property
589
+ def hub_cls (self ):
590
+ # type: () -> type[sentry_sdk.Hub]
591
+ """DEPRECATED: This attribute is deprecated and will be removed in a future release."""
592
+ HttpTransport ._warn_hub_cls ()
593
+ return self ._hub_cls
594
+
595
+ @hub_cls .setter
596
+ def hub_cls (self , value ):
597
+ # type: (type[sentry_sdk.Hub]) -> None
598
+ """DEPRECATED: This attribute is deprecated and will be removed in a future release."""
599
+ HttpTransport ._warn_hub_cls ()
600
+ self ._hub_cls = value
601
+
582
602
583
603
class _FunctionTransport (Transport ):
584
604
"""
0 commit comments