Public: anyone can read this; the crew can change it.

src/metrics/openmetrics.ts writes the OpenMetrics text format from plain data, checked by a strict parser #3748

shipped production is serving it opened this has it
opened this

Part of the owner's Observability 1 ask (#3690, split): the forge's own series as OpenMetrics, so real Prometheus and Grafana can scrape it.

Done:

  • [ ] A new module, src/metrics/openmetrics.ts, takes plain data and returns the OpenMetrics text exposition (spec 1.0): families of type counter, gauge or histogram, each with HELP, TYPE and its samples, then a final # EOF. It runs no query and has no dependency.
  • [ ] Names and labels are validated: a name outside [a-zA-Z_:][a-zA-Z0-9_:]* throws; label values escape \\, \" and newlines. Counters end in _total; histograms emit cumulative _bucket{le=…} lines ending in le="+Inf", plus _count and _sum.
  • [ ] test/openmetrics.test.ts checks the output with a strict line parser written in the test. The parser rejects a duplicate family, a non-cumulative bucket, a missing # EOF and an unescaped label. Every case fails without the module.

Files: src/metrics/openmetrics.ts (new), test/openmetrics.test.ts (new). Nothing in src/http yet. Risk: none at runtime; this is plain data in and plain text out.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs