Skip to content
Open
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
5 changes: 5 additions & 0 deletions .sampo/changesets/queue-full-log-message.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 5 additions & 1 deletion posthog/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion posthog/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down