Repository navigation
Conversation
| // le labels, including +Inf), plus _sum and _count. | ||
| func Map(mp embed.MetricPoint) (MetricFamily, error) { | ||
| base := sanitizeName(mp.Name) | ||
| labels := sortedLabels(mp.Metadata.Attributes) |
There was a problem hiding this comment.
Labels come only from Metadata.Attributes; Metadata.Resource, where host identity lives, is never read. With hostmetrics at workers: 4 against a real Prometheus, system_memory_usage ends up with 4 series ({state=…}) instead of 16, and there's no host label. Every simulated host writes into the same series. In remote-write this causes 400 duplicate sample for timestamp … overrides not allowed, which drops the whole batch (5 of them in a 15s run). In scrape, hosts overwrite each other.
Resource attributes need to become labels, or at least job/instance plus target_info, following the OTel→Prometheus convention.
| samples = append(samples, | ||
| Sample{Name: base + "_bucket", Labels: withLE(labels, "+Inf"), Value: float64(cumulative), TimestampMS: tsMS}, | ||
| Sample{Name: base + "_sum", Labels: labels, Value: mp.HistogramSum, TimestampMS: tsMS}, | ||
| Sample{Name: base + "_count", Labels: labels, Value: float64(mp.HistogramCount), TimestampMS: tsMS}, |
There was a problem hiding this comment.
_count comes from HistogramCount instead of the cumulative +Inf total, so the two can disagree.
…P-471) Assisted-By: Claude Opus 4.8
…count from +Inf Assisted-By: Claude Opus 5.5
Assisted-By: Claude Opus 5.5
06e4933 to
313d507
Compare
Proposed Change
Adds
internal/prommap, the shared layer the two Prometheus outputs (prometheus-remote-write,prometheus-scrape) build on. It maps an embedMetricPointto the in-memory model both the scrape (text) and remote-write (protobuf) encoders serialize from.Type mapping: gauge and sum to gauge, counter to counter (
_total), histogram to histogram (_bucket/_sum/_count). Histogram buckets are cumulative withlelabels, including+Inf. Names are sanitized to the Prometheus grammar. Labels are sorted,lelast. HELP, TYPE, unit, and millisecond timestamps come from theMetricPoint.Checklist