Skip to content

Conversation

@jpalharini
Copy link

@jpalharini jpalharini commented Oct 13, 2025

This is a refactor idea for iapetos to use the new Prometheus Client Java.

This new library introduces lots of breaking changes compared to the previous simpleclient, as announced by Grafana Labs, but this refactor aims to make iapetos as non-breaking as possible while also not relying on the compatibility layer.

Breaking changes

All registered metrics should have a explicit type.

It is no longer possible to register a Collector, only an instance of Counter, Gauge, Histogram or Summary.

In order to achieve similar functionality we need to have support for adding callbacks to metric instances.

New internal type for distribution metrics

valAt or invoke methods on the IapetosRegistry will return a new type for metrics of distribution type (histogram and summary): iapetos.collector/LabeledDistributionCollector.

This is because it's impossible to retrieve current values from what we call a "label-instance" in distribution metrics, so we need the "parent" or "non-labeled" instance of the metric to remain accessible.

I have an open issue in the Client Java repository to clarify intention.

Naming suffixes

It is no longer allowed to have the name of a metric that is not of type Counter suffixed by 'total'. I believe this is a push to align Prometheus with OpenMetrics standards. This also means that metrics of type Counter will be suffixed by 'total' automatically.

I have added an assertion to iapetos.collector/instantiate to help users understand what is happening instead of getting a "invalid metric name" generic error from the Prometheus Client.

Metrics with no labels have an initial value

If a metric is registered with no labels, it will be automatically initialized to a value of 0.0 when scraping or obtaining the metric value.

Changes to text format

The text format, exported using iapetos.export/text-format no longer includes name, type and help text for all registered metrics, only when they have a value or have no configured labels. The latter will have an initial value as described in the previous section.

Changes to JVM metrics

JVM metrics (under iapetos.collector.jvm) now need to be instantiated as a reified type as they need special handling on registry (call .register() on the metric and not on the registry) and cannot be instantiated using a Builder (as they already are).

Some JVM metrics changed names:

Old Metric Name New Metric Name
jvm_memory_bytes_committed jvm_memory_committed_bytes
jvm_memory_bytes_init jvm_memory_init_bytes
jvm_memory_bytes_max jvm_memory_max_bytes
jvm_memory_pool_bytes_committed jvm_memory_pool_committed_bytes
jvm_memory_pool_bytes_init jvm_memory_pool_init_bytes
jvm_memory_pool_bytes_max jvm_memory_pool_max_bytes
jvm_memory_pool_bytes_used jvm_memory_pool_used_bytes
jvm_memory_pool_collection_bytes_committed jvm_memory_pool_collection_committed_bytes
jvm_memory_pool_collection_bytes_init jvm_memory_pool_collection_init_bytes
jvm_memory_pool_collection_bytes_max jvm_memory_pool_collection_max_bytes
jvm_memory_pool_collection_bytes_used jvm_memory_pool_collection_used_bytes
jvm_info jvm_runtime_info

@jpalharini jpalharini requested a review from xsc as a code owner October 13, 2025 14:32
@jpalharini jpalharini force-pushed the prometheus-java-1.0 branch 2 times, most recently from 7549e5b to ef34338 Compare October 13, 2025 14:34
@jpalharini jpalharini marked this pull request as draft October 13, 2025 14:42
@jpalharini jpalharini marked this pull request as ready for review October 13, 2025 15:11
@jpalharini
Copy link
Author

jpalharini commented Oct 14, 2025

Work to add callbacks, in order to allow for functionality similar to what was usually achieved through use of iapetos.collector/named, is being tracked in a separate branch: metrics-with-callbacks.

Let me know if you believe it makes sense to merge with this refactor.

There is no replacement for .metricFamilySamples on the raw registry
@jpalharini
Copy link
Author

Moving to draft as Prometheus' client-java maintainers added public methods for sum and count of distribution metrics. This will significantly simplify the code.

prometheus/client_java#1669

@jpalharini jpalharini marked this pull request as draft November 11, 2025 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant