NPE setting .labelNames while using Gauge.Time.startTimer()

23 views
Skip to first unread message

Imran Ansari

unread,
Aug 26, 2020, 5:16:44 PM8/26/20
to Prometheus Users
Hello,

Not sure why I get a NPE when setting the `labelNames`, I'm able to provide labels just fine using the REST API directly but not with the Java Client, skipping the labels in Java does work fine as well, what gives ?

        CollectorRegistry registry = new CollectorRegistry();
        final Gauge duration = Gauge.build()
                .name(metricName)
                .labelNames("l1", "l2")
                .help("Duration in seconds.")
                .register(registry)
        Gauge.Timer durationTimer = duration.startTimer();



java.lang.NullPointerException
at io.prometheus.client.Gauge.startTimer(Gauge.java:283)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)

Reply all
Reply to author
Forward
0 new messages