Skip to content

Content negotiation is broken for expfmt and for promhttp #456

@jonatan-ivanov

Description

@jonatan-ivanov

According to this comment on OTel's Prometheus exporter expfmt and promhttp are returning the wrong format if openmetrics-text 1.0.0 is requested. It seems openmetrics-text 1.0.0 is not supported only openmetrics-text 0.0.1 is.

If a user requests openmetrics-text 1.0.0:

Accept: application/openmetrics-text; version=1.0.0; charset=utf-8

The expected result should be in the OpenMetrics format, also the content-type should be:

Content-Type: application/openmetrics-text; version=1.0.0; charset=utf-8

But the result is in Prometheus plaintext format, the content-type says the same:

Content-Type: text/plain; version=0.0.4; charset=utf-8

If a user requests openmetrics-text 0.0.1:

Accept: application/openmetrics-text; version=0.0.1; charset=utf-8

The result is in the expected OpenMetrics format:

Content-Type: application/openmetrics-text; version=0.0.1; charset=utf-8

As far as I know, 0.0.1 should not be used, only 1.0.0.
According to the OpenMetrics specs:

The content type MUST be: application/openmetrics-text; version=1.0.0; charset=utf-8

Also the Prometheus server uses 1.0.0 for scraping: prometheus/prometheus#9430

Metadata

Metadata

Assignees

No one assigned

    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