Skip to content

fix(exporter): hi_jetstream_events_total is a Counter (#172)#517

Merged
mvillmow merged 1 commit into
mainfrom
172-jetstream-events-counter
May 14, 2026
Merged

fix(exporter): hi_jetstream_events_total is a Counter (#172)#517
mvillmow merged 1 commit into
mainfrom
172-jetstream-events-counter

Conversation

@mvillmow
Copy link
Copy Markdown
Contributor

Summary

  • Render hi_jetstream_events_total and hi_jetstream_consumer_last_seq as Prometheus counter types instead of gauge. Both values already accumulate monotonically in the consumer (_event_counts[k] += 1, _last_seq is a high-water mark), so only the exposition # TYPE line was wrong.
  • This restores counter-reset detection for rate() queries — after a consumer restart, the value drops to 0; with the old gauge type, rate() produced a misleading spike instead of treating the drop as a reset.
  • hi_jetstream_task_latency_seconds, hi_jetstream_consumer_connected, and hi_jetstream_consumer_scrape_timestamp remain gauges (they are instantaneous values, not monotonic).

Closes #172

Test plan

  • pytest tests/test_jetstream_consumer.py — 35/35 pass
  • New assertions lock in # TYPE hi_jetstream_events_total counter and # TYPE hi_jetstream_consumer_last_seq counter
  • Negative assertions ensure the old gauge TYPE line is no longer emitted for these metrics
  • Gauge-typed metrics (hi_jetstream_task_latency_seconds, hi_jetstream_consumer_connected) retain their gauge TYPE lines

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

)

Render hi_jetstream_events_total and hi_jetstream_consumer_last_seq with
'# TYPE ... counter' so Prometheus's rate() applies counter-reset detection
(e.g. when a consumer restarts and the value drops back to zero). The
underlying accumulators already behave monotonically — only the exposition
type was wrong.

hi_jetstream_task_latency_seconds, hi_jetstream_consumer_connected, and
hi_jetstream_consumer_scrape_timestamp remain gauges (instantaneous values).

Closes #172

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mvillmow mvillmow enabled auto-merge (squash) May 14, 2026 03:01
@mvillmow mvillmow merged commit 9b1f195 into main May 14, 2026
20 checks passed
@mvillmow mvillmow deleted the 172-jetstream-events-counter branch May 14, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose hi_jetstream_events_total as a true counter, not a gauge

1 participant