Skip to content

Commit

Permalink
chore: more realtime data (#23010)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Jun 17, 2024
1 parent 056ac0b commit 9760f13
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion posthog/session_recordings/realtime_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9760f13

Please sign in to comment.