From 9760f1387c5092e55165cd3384233cc314d99bd5 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Mon, 17 Jun 2024 11:40:39 +0100 Subject: [PATCH] chore: more realtime data (#23010) --- posthog/session_recordings/realtime_snapshots.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/posthog/session_recordings/realtime_snapshots.py b/posthog/session_recordings/realtime_snapshots.py index 9e51d759a28b6..d3b0b54a5c978 100644 --- a/posthog/session_recordings/realtime_snapshots.py +++ b/posthog/session_recordings/realtime_snapshots.py @@ -3,7 +3,7 @@ from typing import Optional import structlog -from prometheus_client import Counter +from prometheus_client import Counter, Histogram from posthog import settings from posthog.redis import get_client @@ -23,6 +23,12 @@ labelnames=["attempt_count"], ) +REALTIME_SUBSCRIPTIONS_DATA_LENGTH = Histogram( + "realtime_snapshots_data_length", + "The length of the data received from the realtime channel. It's ok for this to be zero _some times_ an increase in the rate of zero indicates a possible issue.", + labelnames=["attempt_count"], +) + SUBSCRIPTION_CHANNEL = "@posthog/replay/realtime-subscriptions" @@ -91,6 +97,7 @@ def get_realtime_snapshots(team_id: str, session_id: str, attempt_count=0) -> Op snapshots.append(line.decode("utf8")) REALTIME_SUBSCRIPTIONS_LOADED_COUNTER.labels(attempt_count=attempt_count).inc() + REALTIME_SUBSCRIPTIONS_DATA_LENGTH.labels(attempt_count=attempt_count).observe(len(snapshots)) return snapshots return None