Skip to content

fix: correct cbgo_dcp_latency_ms_current metric type from Counter to Gauge#147

Merged
Abdulsametileri merged 1 commit intoTrendyol:masterfrom
nakrenat:dcp-metric-gauge
Mar 13, 2026
Merged

fix: correct cbgo_dcp_latency_ms_current metric type from Counter to Gauge#147
Abdulsametileri merged 1 commit intoTrendyol:masterfrom
nakrenat:dcp-metric-gauge

Conversation

@nakrenat
Copy link
Contributor

What

cbgo_dcp_latency_ms_current was exported as prometheus.CounterValue in
metric/collector.go, but its underlying value is a point-in-time latency
snapshot
that is overwritten on every DCP event — not a monotonically
increasing total.

Why It Matters

Prometheus counters must never decrease. Because latency fluctuates
naturally (fast events produce small values, slow ones produce large values),
this metric regularly decreases between scrapes. This causes:

  • Prometheus to emit stale-marker errors or silently drop decreasing counter samples
  • rate() and increase() PromQL functions to return incorrect or zero results
  • Grafana panels and alerts based on this metric to show misleading data

The inconsistency is easy to confirm by comparing the two latency metrics
side by side in collector.go:

// processLatency — correctly exported as GaugeValue
ch <- prometheus.MustNewConstMetric(s.processLatency, prometheus.GaugeValue, ...)

// dcpLatency — incorrectly exported as CounterValue  ← this PR fixes it
ch <- prometheus.MustNewConstMetric(s.dcpLatency, prometheus.CounterValue, ...)

Copy link
Member

@mhmtszr mhmtszr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the pr.

@Abdulsametileri Abdulsametileri self-requested a review March 13, 2026 13:41
@Abdulsametileri Abdulsametileri merged commit c67ceac into Trendyol:master Mar 13, 2026
21 of 22 checks passed
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.

3 participants