[fix][monitor] Set correct content-type for metrics endpoints in Pulsar for Prometheus 3.x compatibility #24065
+26
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Follow up on #24060 which set an incorrect content type.
Metrics endpoint uses version 1.0.0 of the Prometheus/OpenMetrics text format.
This content-type value ensures compatibility with Prometheus 3.x and later versions.
For details, refer to the Prometheus 3.x migration guide:
https://prometheus.io/docs/prometheus/latest/migration/#scrape-protocols
The difference between version 1.0.0 and 0.0.4 formats is mainly about counters.
The prometheus client_java library >=0.10.0 creates OpenMetrics compatible counters which are not compatible with the 0.0.4 format which is currently in use in BookKeeper.
For implementation details of Prometheus client_java, see:
https://github.com/prometheus/client_java/blob/parent0.16.0/simpleclient/src/main/java/io/prometheus/client/Counter.java#L76-L80
The library will always append "_total" to the counter name unless the counter name already contains "_total" suffix and will have a separate "_created" counter to ensure OpenMetrics compatibility. This change was introduced in prometheus/client_java#615 in version 0.10.0.
Release notes: https://github.com/prometheus/client_java/releases/tag/parent-0.10.0
In Pulsar, the Prometheus client_java library was updated to 0.15.0 with #13785 in Pulsar 2.11.0.
Modifications
Documentation
doc
doc-required
doc-not-needed
doc-complete