Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Counts in ClassicHistogramBuckets cannot be negative throws when using SimpleclientCollector bridge #887

Closed
turchenkoalex opened this issue Nov 1, 2023 · 0 comments

Comments

@turchenkoalex
Copy link
Contributor

turchenkoalex commented Nov 1, 2023

If I use non-integer numbers in buckets for a classic histogram, an error is thrown when scraping metrics

Sample code to reproduce the error

package io.prometheus.metrics.simpleclient.bridge;

import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.Histogram;
import io.prometheus.metrics.model.registry.PrometheusRegistry;

public class Test {
    public static void main(String[] args) {
        CollectorRegistry origRegistry = new CollectorRegistry();
        PrometheusRegistry newRegistry = new PrometheusRegistry();
        SimpleclientCollector.builder()
                .collectorRegistry(origRegistry)
                .register(newRegistry);

        Histogram histogram = Histogram.build()
                .name("response_size_bytes")
                .help("response size in Bytes")
                .labelNames("status")
                .buckets(0.01, 0.1)
                .register(origRegistry);

        histogram.labels("200").observe(1);

        newRegistry.scrape(); // throws IllegalArgumentException: Counts in ClassicHistogramBuckets cannot be negative.
    }
}
turchenkoalex added a commit to turchenkoalex/client_java that referenced this issue Nov 1, 2023
turchenkoalex added a commit to turchenkoalex/client_java that referenced this issue Nov 1, 2023
Signed-off-by: Aleksandr Turchenko <aleksandr.turchenko@lightspeedhq.com>
fstab pushed a commit that referenced this issue Nov 2, 2023
Signed-off-by: Greg Eales <0x006ea1e5@gmail.com>
fstab pushed a commit that referenced this issue Nov 2, 2023
Signed-off-by: Aleksandr Turchenko <aleksandr.turchenko@lightspeedhq.com>
@fstab fstab closed this as completed Nov 2, 2023
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

No branches or pull requests

2 participants