File tree 3 files changed +17
-24
lines changed
3 files changed +17
-24
lines changed Original file line number Diff line number Diff line change @@ -59,21 +59,9 @@ def _thread():
59
59
def run (self ):
60
60
# type: () -> None
61
61
self .check_health ()
62
- self ._set_downsample_factor ()
62
+ self .set_downsample_factor ()
63
63
64
- def _is_transport_rate_limited (self ):
65
- # type: () -> bool
66
- if self .transport and hasattr (self .transport , "is_rate_limited" ):
67
- return self .transport .is_rate_limited ()
68
- return False
69
-
70
- def _is_transport_worker_full (self ):
71
- # type: () -> bool
72
- if self .transport and hasattr (self .transport , "is_worker_full" ):
73
- return self .transport .is_worker_full ()
74
- return False
75
-
76
- def _set_downsample_factor (self ):
64
+ def set_downsample_factor (self ):
77
65
# type: () -> None
78
66
if self ._healthy :
79
67
if self ._downsample_factor > 1 :
@@ -95,10 +83,7 @@ def check_health(self):
95
83
currently only checks if the transport is rate-limited.
96
84
TODO: augment in the future with more checks.
97
85
"""
98
- if self ._is_transport_worker_full () or self ._is_transport_rate_limited ():
99
- self ._healthy = False
100
- else :
101
- self ._healthy = True
86
+ self ._healthy = self .transport .is_healthy ()
102
87
103
88
def is_healthy (self ):
104
89
# type: () -> bool
Original file line number Diff line number Diff line change @@ -107,6 +107,10 @@ def record_lost_event(
107
107
"""
108
108
return None
109
109
110
+ def is_healthy (self ):
111
+ # type: () -> bool
112
+ return True
113
+
110
114
def __del__ (self ):
111
115
# type: () -> None
112
116
try :
@@ -311,14 +315,18 @@ def _disabled(bucket):
311
315
312
316
return _disabled (category ) or _disabled (None )
313
317
314
- def is_rate_limited (self ):
318
+ def _is_rate_limited (self ):
315
319
# type: () -> bool
316
320
return any (ts > datetime .utcnow () for ts in self ._disabled_until .values ())
317
321
318
- def is_worker_full (self ):
322
+ def _is_worker_full (self ):
319
323
# type: () -> bool
320
324
return self ._worker .full ()
321
325
326
+ def is_healthy (self ):
327
+ # type: () -> bool
328
+ return not (self ._is_worker_full () or self ._is_rate_limited ())
329
+
322
330
def _send_event (
323
331
self , event # type: Event
324
332
):
Original file line number Diff line number Diff line change @@ -11,13 +11,13 @@ def _send_event(self, event):
11
11
def _send_envelope (self , envelope ):
12
12
pass
13
13
14
- def is_worker_full (self ):
15
- return False
14
+ def is_healthy (self ):
15
+ return True
16
16
17
17
18
18
class UnhealthyTestTransport (HealthyTestTransport ):
19
- def is_worker_full (self ):
20
- return True
19
+ def is_healthy (self ):
20
+ return False
21
21
22
22
23
23
def test_no_monitor_if_disabled (sentry_init ):
You can’t perform that action at this time.
0 commit comments