-
Notifications
You must be signed in to change notification settings - Fork 868
prometheus middleware #1892
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
prometheus middleware #1892
Conversation
There are two parts to this PR: - we annotate existing stats as 'gauge', so that we can default all other stats as 'counter' - we add an mruby helper and associated doc that consumes a status hander to produce stats in a Prometheus format
|
while working on this, I feel I want to move (snip)
keys.each { |k,v|
type = if k =~ /\Auptime|connections|num-sessions\z/
'gauge'
elsif k =~ /-[0-9]+\z/
'gauge'
else
'counter'
end
s += "#HELP #{k}\n"
s += "#TYPE #{k} #{type}\n"
s += "#{k}{version=\"#{version}\"} #{v}\n"
}
(snip)I think it's clearer than the current way, WDYT @deweerdt @kazuho ? |
|
This looks awesome. The mruby script acts as a wrapper ("middleware" in terms of Rack), removing the need to use HTTP in order to fetch the status information from another handler. @deweerdt Would you mind reviewing the PR? |
|
@i110 thanks! This is a nice improvement. I'm not sure how i feel about the type being derived from the appearance. It does work for now, and skipping the C part of the PR is an advantage. On the other hand, whether a stat is a counter or a gauge is something that the consumer can't tell, so we'll have to be cognizant of this when adding new counters. Thanks again :) LGTM. |
|
@deweerdt Thank you for the review.
My view is that generally speaking "deriving type from appearance" is the correct thing to do. Consider Having that said, to me the questions seems to be if we would be fine with using a naming convention that is capable of distinguishing between gauges and other types (welcome to the world of Hungarian notation!), or if we need to associate the "types" as attributes. I do not have a strong opinion on the matter. |
…y script - make it more comformant to https://prometheus.io/docs/instrumenting/writing_exporters
|
I pushed 0035ed9, which does type-related things in mruby script, and also make some changes regarding the doc: https://prometheus.io/docs/instrumenting/writing_exporters (e.g. sanitizing the keys, removing not numeric fields, etc) What do you think? Personally I'm gladI could remove c code changes. Anyway we may have to read the above doc more.. |
Yes, agreed. I think the approach take here is good. |
|
For record: @kazuho @deweerdt thank you for discussing with me. I think this PR is ready for merge if you have no concerns |
|
d8eb74c added |
Rewrites #1831 using mruby middleware.
an example usage from updated doc: