mirror of
https://github.com/hanzoai/o11y.git
synced 2026-10-30 14:56:15 +00:00
github.com/hanzoai/metrics carries a NOTICE naming this module its successor, and it is archived and read-only. What the NOTICE did not say is that the code was still running: hanzoai/cloud went on importing the archive and mounting it for /v1/metrics, /v1/logs and /v1/traces, so a repository nobody can push to held eleven live routes and the store behind them. A succession is only finished when the successor has the code. It arrives whole — the per-tenant WAL store, the ZAP MetricBatch receiver, the routes and their tests — and the tests pass here unchanged but for the addresses. The addresses fold per HIP-1241: every route is under /v1/metrics, so the two foreign roots the archive answered on become /v1/metrics/logs/* and /v1/metrics/traces/*. Forward only; nothing answers at the old spelling. This store is its own. The event.* columnar plane the rest of this module reads is a different store of a different shape, and the succession note's claim that o11y already held this signal store was true only of that plane — these eleven routes had no home here until now. They share the module and nothing else. The tenant decision still comes from the host (Deps.Org), so the boundary that authenticates keeps naming the org and this package never reads a header.
34 lines
1020 B
Go
34 lines
1020 B
Go
package metrics
|
|
|
|
import metric "github.com/luxfi/metric"
|
|
|
|
// IngestBatch writes every sample in a luxfi/metric.MetricBatch into the store.
|
|
// This is the exact wire type the ZAP MsgMetricBatch transport carries, so the
|
|
// same code path serves both the HTTP /v1/metrics/batch endpoint and a future
|
|
// ZAP receiver. Counter/gauge values land directly; histogram/summary families
|
|
// contribute derived <name>_sum and <name>_count series. Returns samples written.
|
|
func (s *Store) IngestBatch(b *metric.MetricBatch) int {
|
|
if b == nil {
|
|
return 0
|
|
}
|
|
ts := b.TimestampNs
|
|
n := 0
|
|
for _, fam := range b.Families {
|
|
for _, m := range fam.Metrics {
|
|
if m.Value != nil {
|
|
s.Append(fam.Name, m.Labels, Sample{TsNs: ts, Value: *m.Value})
|
|
n++
|
|
}
|
|
if m.SampleSum != nil {
|
|
s.Append(fam.Name+"_sum", m.Labels, Sample{TsNs: ts, Value: *m.SampleSum})
|
|
n++
|
|
}
|
|
if m.SampleCount != nil {
|
|
s.Append(fam.Name+"_count", m.Labels, Sample{TsNs: ts, Value: float64(*m.SampleCount)})
|
|
n++
|
|
}
|
|
}
|
|
}
|
|
return n
|
|
}
|