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

Histogram startTimer() fails when applying labelNames #3225

Closed
acarlstein opened this Issue Sep 26, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@acarlstein
Copy link

acarlstein commented Sep 26, 2017

#How you doing?
I apologize to bother you but I think I may have encounter a possible bug.
I tried to find any solution or explanation to the problem unsuccessfully, else I would not be bothering you.

In Java or Groovy, this works:

Histogram requestLatency = Histogram.build().name("xrequests_latency_seconds").help("Request latency in seconds.").register();
Histogram.Timer requestTimer = requestLatency.startTimer();
try {
	TimeUnit.SECONDS.sleep(1);
} finally {
	requestTimer.observeDuration();
}

While this fails:

Histogram requestLatency = Histogram.build().name("xrequests_latency_seconds").help("Request latency in seconds.").labelNames("Feeling").register();
Histogram.Child histogramChild = requestLatency.labels("sleepy");									
Histogram.Timer requestTimer = requestLatency.startTimer();
try {
	TimeUnit.SECONDS.sleep(1);
} finally {
	requestTimer.observeDuration();
}

Producing this Exception:

java.lang.NullPointerException at io.prometheus.client.Histogram.startTimer(Histogram.java:282)

I have apply similar approach using labels with Counter and Gauge, no problems there.

Note: I am using io.prometheus:simpleclient_common:0.0.20 and io.prometheus:simpleclient:0.0.26

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Sep 27, 2017

This is correct, for a labelled metric you must specify the labels.

It makes more sense to ask questions like this on the prometheus-users mailing list rather than in a GitHub issue. On the mailing list, more people are available to potentially respond to your question, and the whole community can benefit from the answers provided.

@acarlstein

This comment has been minimized.

Copy link
Author

acarlstein commented Sep 27, 2017

@brian-brazil,

Since English is my second language, I may have explained myself wrong. For that I apologize.

Histogram is failing when I am applying the labels.
The second code example I provided ends in NullPointerException.
Is this supposed to happen? If so, why?

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 23, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.