Metrics API (count, gauge, histogram) now in alpha
posthog-v7.23.0
Minor changes
-
5e42b1e Add the
posthog.metricsAPI (count,gauge,histogram) — alpha.Backend services can now record metrics through the same statsd-style pre-aggregating client the browser SDK ships, with no OpenTelemetry setup:
client = Posthog("<ph_project_api_key>", metrics={"service_name": "billing-worker"}) client.metrics.count("invoices.processed", 1, attributes={"plan": "pro"}) client.metrics.gauge("queue.depth", 42) client.metrics.histogram("job.duration", 187, unit="ms")Samples aggregate in memory and flush as OTLP/JSON to
/i/v1/metrics(one data point per series per window, delta temporality). Pending metrics are flushed onshutdown(); buffered windows are retried on transient failures and dropped loudly after 3 consecutive failed flushes. Themetricsclient option acceptsservice_name,service_version,environment,resource_attributes,flush_interval(seconds),max_series_per_flush(cardinality guardrail, default 1000), and abefore_sendhook. — Thanks @DanielVisca!
Fetched July 15, 2026
