-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-27395 Adding description to Prometheus metrics #4807
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
Conversation
Change-Id: I5f76b741c3419c4f2d355252d9a958ee48784257
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
String tmpStr = req.getParameter("description"); | ||
boolean description = tmpStr != null && tmpStr.equals("true"); | ||
|
||
writeMetrics(resp.getWriter(), description); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be compacted like this:
writeMetrics(resp.getWriter(), "true".equals(req.getParameter("description")));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally agree, should have noticed that. Thank you!
@@ -57,13 +60,19 @@ static String toPrometheusName(String metricRecordName, String metricName) { | |||
*/ | |||
@RestrictedApi(explanation = "Should only be called in tests or self", link = "", | |||
allowedOnPath = ".*/src/test/.*|.*/PrometheusHadoopServlet\\.java") | |||
void writeMetrics(Writer writer) throws IOException { | |||
void writeMetrics(Writer writer, boolean desc) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe 'describe' is better argument name than 'desc'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use 'desc', because 'description' is used as a local variable name in the function
|
||
if (desc) { | ||
String description = metrics.description(); | ||
if (!description.isEmpty()) writer.append("# HELP ").append(description).append("\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you append a single char to the writer you can use the append(char c) instead if of append(CharSequence csq). I mean
.append('\n'
)
instead of
.append("\n")
Doesn't make much difference but slightly cheaper..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it, thanks for the info!
Notes: - Made some improvements in the code based on the review
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
Signed-off-by: Tamas Payer <payert@apache.org> Signed-off-by: Balazs Meszaros <meszibalu@apache.org>
Signed-off-by: Tamas Payer <payert@apache.org> Signed-off-by: Balazs Meszaros <meszibalu@apache.org> (cherry picked from commit f5df769) Change-Id: I7718263ee568a51bab9ed4ed03b0e26f915ab31c
You can access metrics description while using '/prometheus' endpoint via "description=true" URL parameter.
Example:
http://HOSTNAME:16010/prometheus?description=true
Apache JIRA: https://issues.apache.org/jira/browse/HBASE-27395