diff --git a/.sampo/changesets/queue-full-log-message.md b/.sampo/changesets/queue-full-log-message.md new file mode 100644 index 00000000..9416b3c5 --- /dev/null +++ b/.sampo/changesets/queue-full-log-message.md @@ -0,0 +1,5 @@ +--- +pypi/posthog: patch +--- + +Clarify the queue-full warning to say the event is being dropped, instead of only reporting that the queue is full. diff --git a/posthog/client.py b/posthog/client.py index 7bcfb591..e645e235 100644 --- a/posthog/client.py +++ b/posthog/client.py @@ -1712,7 +1712,11 @@ def _enqueue(self, msg, disable_geoip): self.log.debug("enqueued %s.", msg["event"]) return sent_uuid except Full: - self.log.warning("analytics-python queue is full") + self.log.warning( + "event queue is full (maxsize %d), dropping event %s", + self.queue.maxsize, + msg["event"], + ) return None def flush(self, timeout_seconds: Optional[float] = 10) -> None: diff --git a/posthog/test/test_client.py b/posthog/test/test_client.py index 0cdf2ece..49bcc9b7 100644 --- a/posthog/test/test_client.py +++ b/posthog/test/test_client.py @@ -2114,9 +2114,11 @@ def test_overflow(self): for i in range(10): client.capture("test event", distinct_id="distinct_id") - msg_uuid = client.capture("test event", distinct_id="distinct_id") + with self.assertLogs("posthog", level="WARNING") as logs: + msg_uuid = client.capture("test event", distinct_id="distinct_id") # Make sure we are informed that the queue is at capacity self.assertIsNone(msg_uuid) + self.assertIn("dropping event", logs.output[0]) def test_unicode(self): Client("unicode_key")