-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add the last few lines needed to show a new user how the Collector/Gatherer fits together #495
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
Add the last few lines needed to show a new user how the Collector/Gatherer fits together #495
Conversation
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.
The example is not really meant to handle the promhttp part, but I'm not opposed to making this anyway quite long example a bit more comprehensive. But see my comments for details...
|
||
// Because we've registered these metrics to a new non-default Registry | ||
// we need to tell it to servce them separately | ||
http.Handle("/metrics/inner", promhttp.HandlerFor(reg, promhttp.HandlerOpts{})) |
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 would not recommend to serve those metrics separately.
If you would like to see the standard process and Go metrics, it's better to register the respective collectors with the custom registry. It might actually be a good idea to demonstrate that here, turning this into a very comprehensive example.
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.
aha, another thing i haven't worked out how to do - will do some more reading :)
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.
The code is the following:
reg.MustRegister(
prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}),
prometheus.NewGoCollector(),
)
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.
ping Would you like to add the above and then remove the exposition of the default registry?
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.
yup, sorry, $work is distracting :)
http.Handle("/metrics/inner", promhttp.HandlerFor(reg, promhttp.HandlerOpts{})) | ||
|
||
// The default golang metrics | ||
http.Handle("/metrics", prometheus.Handler()) |
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.
In the spirit of the above, I would drop this line.
913cd43
to
218f588
Compare
…therer fits together Signed-off-by: Dowideit, Sven (O&A, St. Lucia) <Sven.Dowideit@csiro.au>
218f588
to
8324e65
Compare
aha, and that simplifies the code i'm using too - worth iterating - thanks for taking the time :) |
Thank you, too. |
Or if that's too verbose, can we just add the
http.Handle("/metrics/inner", promhttp.HandlerFor(reg, promhttp.HandlerOpts{}))
line to help the new user?