After upgrading from 2.5.5 to 2.5.6 I noticed my browser started downloading a file rather than displaying the Prometheus metrics in the tab. This makes it a little tedious to work with.

Anyway, the Accept header my browser is sending is: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9

... and the responses from 2.5.5 and 2.5.6 are:

2.5.5: Content-Type: text/plain;version=0.0.4;charset=utf-8 2.5.6: Content-Type: application/openmetrics-text;version=1.0.0;charset=utf-8

I made a minimal example on Github - just change the version of the Spring Boot parent in pom.xml to reproduce: https://github.com/ThomasKasene/example-spring-boot-prometheus

My hunch says this might be related to the discussions over at #28130 or #28137, but I'm not completely sure.

EDIT: I should point out that I don't actually know whether this is considered a bug, or if it's "working as intended", and that the browser is the one at fault.

Comment From: wilkinsona

From the Accept header's perspective, both 2.5.5 and 2.5.6 are behaving correctly as no preference is being expressed between text/plain and application/openmetrics-text. It's */* that matches both of those. From Prometheus's perspective, we've made a mistake in 2.5.6 and you're right that it's related to https://github.com/spring-projects/spring-boot/issues/28130.

On #28130, I said the following:

We're going to align with TextFormat. It ignores versions and quality. If there's an accept header and it contains application/openmetrics-text it produces application/openmetrics-text; version=1.0.0; charset=utf-8 otherwise it produces text/plain; version=0.0.4; charset=utf-8.

Unfortunately, this isn't what we implemented. We correctly prefer to produce application/openmetrics-text if it's explicitly accepted but we also serve it by default. To align with TextFormat, we should be serving text/plain by default. Happily for you, correcting this will also improve the situation when accessing the endpoint with a browser.