8000 fix(worker): Log data-dropping events with error · getsentry/sentry-python@d72f1d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit d72f1d2

Browse files
committed
fix(worker): Log data-dropping events with error
When we fail to flush all events, or when the queue overflows, this should be an error event. I have some concerns about when the user uses things like logly, which are known for sending out blocking HTTP requests from within their log handler. However I believe they don't register that handler for all loggers.
1 parent 37105d9 commit d72f1d2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sentry_sdk/worker.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,15 @@ def _wait_flush(self, timeout, callback):
9999
# type: (float, Optional[Any]) -> None
100100
initial_timeout = min(0.1, timeout)
101101
if not self._timed_queue_join(initial_timeout):
102-
pending = self._queue.qsize()
102+
pending = self._queue.qsize() + 1
103103
logger.debug("%d event(s) pending on flush", pending)
104104
if callback is not None:
105105
callback(pending, timeout)
106-
self._timed_queue_join(timeout - initial_timeout)
106+
107+
if not self._timed_queue_join(timeout - initial_timeout):
108+
pending = self._queue.qsize() + 1
109+
logger.error("flush timed out, dropped %s events", pending)
110+
107111

108112
def submit(self, callback):
109113
# type: (Callable[[], None]) -> None
@@ -115,7 +119,7 @@ def submit(self, callback):
115119

116120
def on_full_queue(self, callback):
117121
# type: (Optional[Any]) -> None
118-
logger.debug("background worker queue full, dropping event")
122+
logger.error("background worker queue full, dropping event")
119123

120124
def _target(self):
121125
# type: () -> None

0 commit comments

Comments
 (0)
0