releases.shpreview

Metrics API (count, gauge, histogram) now in alpha

posthog-v7.23.0

1 featureThis release1 featureNew capabilitiesAI-tallied from the release notes
From the original release noteView original ↗

Minor changes

  • 5e42b1e Add the posthog.metrics API (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 on shutdown(); buffered windows are retried on transient failures and dropped loudly after 3 consecutive failed flushes. The metrics client option accepts service_name, service_version, environment, resource_attributes, flush_interval (seconds), max_series_per_flush (cardinality guardrail, default 1000), and a before_send hook. — Thanks @DanielVisca!

Fetched July 15, 2026