Skip to content

v1.51 breaks prometheus protobuf format (native histogram support)Β #7659

@anuragagarwal561994

Description

@anuragagarwal561994

Describe the bug
#7355 breaks exporting prometheus metrics via protobuf format which is required for publishing native histogram

In the above change we are removing the shaded protobuf by prometehus library, but the commit added later in the MR c60fbe1 passes the test case but breaks the functionality.

[otel.javaagent 2025-09-16 23:27:51:946 +0530] [prometheus-http-server-1] ERROR io.prometheus.metrics.exporter.httpserver.HttpExchangeAdapter - The Prometheus metrics HTTPServer caught an Exception while trying to send the metrics response.
java.lang.UnsupportedOperationException: Prometheus protobuf writer not available
	at io.prometheus.metrics.expositionformats.PrometheusProtobufWriter.checkAvailable(PrometheusProtobufWriter.java:70)
	at io.prometheus.metrics.expositionformats.PrometheusProtobufWriter.toDebugString(PrometheusProtobufWriter.java:58)
	at io.prometheus.metrics.exporter.common.PrometheusScrapeHandler.writeDebugResponse(PrometheusScrapeHandler.java:158)
	at io.prometheus.metrics.exporter.common.PrometheusScrapeHandler.handleRequest(PrometheusScrapeHandler.java:57)
	at io.prometheus.metrics.exporter.httpserver.MetricsHandler.handle(MetricsHandler.java:33)
	at jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:98)
	at jdk.httpserver/sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:82)
	at jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:101)
	at jdk.httpserver/sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:871)
	at jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:98)
	at jdk.httpserver/sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:847)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Thread.java:1583)

Steps to reproduce

Create a dummy application with the latest opentelemetry-javaagent

public class Main2 {
    public static void main(String[] args) throws InterruptedException {
        System.out.println("Hello World!");
        TimeUnit.SECONDS.sleep(40);
    }
}
-javaagent:opentelemetry-javaagent.jar -Dotel.metrics.exporter=prometheus -Dotel.logs.exporter=none -Dotel.traces.exporter=none -Dotel.javaagent.debug=true -Dotel.metric.export.interval=1000 -Dotel.exporter.prometheus.host=127.0.0.1 -Dotel.exporter.prometheus.port=8889

And then in the browser go to /metrics and click on the prometheus-protobuf

What did you expect to see?
Earlier the metrics was being published in protobuf format

What did you see instead?
Now we get 500 error with the above exception in the applcation log

What version and what artifacts are you using?
Artifacts: opentelemetry-sdk
Version: 1.54

Using opentelemetry-instrumentation-javaagent 2.20

Environment
Compiler: "Temurin 17.0.7"
OS: "Mac OSX"

Tip: React with πŸ‘ to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions