Skip to content

feat: add OpenMetrics2TextFormatWriter skeleton #1948

@zeitlinger

Description

@zeitlinger

Part of #1912. Depends on #1939 (merged).
Blocks content negotiation (PR 1) and OM2 suffix handling in #1947.

Motivation

The OM2 feature flags from #1939 exist but there's no OM2 writer
to apply them to. Content negotiation and suffix handling both need
an OM2 writer class to land their changes in.

Scope

  1. OpenMetrics2TextFormatWriter implementing ExpositionFormatWriter

    • Start as copy of OM1 writer (identical output)
    • CONTENT_TYPE = "application/openmetrics-text; version=2.0.0; charset=utf-8"
    • accepts() same as OM1 (matches any OpenMetrics accept) — no version gating
    • Takes OpenMetrics2Properties from feat: Add OpenMetrics2 configuration support #1939 in builder
  2. Wire into ExpositionFormats

    • Add field + accessor
    • When OM2 is enabled: findWriter() prefers OM2 over OM1
    • When OM2 is not enabled: OM2 writer is not used
  3. No new suffix logic, no composite values, no native histograms

Testability

With OM2 enabled and contentNegotiation=false (default), the OM2
writer is always selected for OpenMetrics requests — masquerades as
OM1 so it's testable with current Prometheus.

Content negotiation then gates it: only route to OM2 when the
scraper sends version=2.0.0.

Open question: Does Prometheus reject responses with
Content-Type: ...; version=2.0.0 when it asked for OM1? If so,
use the OM1 content type string when contentNegotiation=false.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions