-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 HTTP metrics for in-flight requests #5440
Changes from 3 commits
f6c8536
79dea37
c3edb10
7db4419
7f0adc4
18038aa
67edcf2
32503f5
4f1f93e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,10 +9,11 @@ import ( | |||||
) | ||||||
|
||||||
type defaultMetrics struct { | ||||||
requestDuration *prometheus.HistogramVec | ||||||
requestSize *prometheus.SummaryVec | ||||||
requestsTotal *prometheus.CounterVec | ||||||
responseSize *prometheus.SummaryVec | ||||||
requestDuration *prometheus.HistogramVec | ||||||
requestSize *prometheus.SummaryVec | ||||||
requestsTotal *prometheus.CounterVec | ||||||
responseSize *prometheus.SummaryVec | ||||||
inflightHTTPRequests *prometheus.GaugeVec | ||||||
} | ||||||
|
||||||
func newDefaultMetrics(reg prometheus.Registerer, buckets []float64, extraLabels []string) *defaultMetrics { | ||||||
|
@@ -29,26 +30,37 @@ func newDefaultMetrics(reg prometheus.Registerer, buckets []float64, extraLabels | |||||
}, | ||||||
append([]string{"code", "handler", "method"}, extraLabels...), | ||||||
), | ||||||
|
||||||
requestSize: promauto.With(reg).NewSummaryVec( | ||||||
prometheus.SummaryOpts{ | ||||||
Name: "http_request_size_bytes", | ||||||
Help: "Tracks the size of HTTP requests.", | ||||||
}, | ||||||
append([]string{"code", "handler", "method"}, extraLabels...), | ||||||
), | ||||||
|
||||||
requestsTotal: promauto.With(reg).NewCounterVec( | ||||||
prometheus.CounterOpts{ | ||||||
Name: "http_requests_total", | ||||||
Help: "Tracks the number of HTTP requests.", | ||||||
}, | ||||||
append([]string{"code", "handler", "method"}, extraLabels...), | ||||||
), | ||||||
|
||||||
responseSize: promauto.With(reg).NewSummaryVec( | ||||||
prometheus.SummaryOpts{ | ||||||
Name: "http_response_size_bytes", | ||||||
Help: "Tracks the size of HTTP responses.", | ||||||
}, | ||||||
append([]string{"code", "handler", "method"}, extraLabels...), | ||||||
), | ||||||
|
||||||
inflightHTTPRequests: promauto.With(reg).NewGaugeVec( | ||||||
prometheus.GaugeOpts{ | ||||||
Name: "http_inflight_requests", | ||||||
Help: "Current number of active requests.", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we could add a more specific description, something like:
Suggested change
wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's redundant to describe it as a "gauge" in the help, because counters should have the postfix To follow up, I don't think the help should say exactly the same as the metric name. Otherwise the help is not helpful. So I thought, "maybe someone will not know exactly what we mean with 'in-flight' and 'active' is a more commonly used word". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think when the metric ends with I think would be ok keeping There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would be a good idea to define "in-flight" within the help message? 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jessicalins the metrics in the reference you sent that aren't explicitly a gauge are summaries/histograms. They will though generate counters with the I improved the help text for the in-flight HTTP requests metrics in |
||||||
}, | ||||||
append([]string{"handler"}, extraLabels...), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the other metrics also consider a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked around the codebase and found some examples of this metric and none of them had the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm interesting. I guess we could add the method label to all of them but i won't block anything, in other words won't let perfect be the enemy of good. Why would we want that label? I guess for the same reason we would want that label on any HTTP handler metric, like all of the other metrics in this file have. The mantra in Prometheus is "instrument first, ask questions later". Said differently, better to have too many metrics than too few. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 32503f5. I was looking into adding this label to the current code, but |
||||||
), | ||||||
} | ||||||
} |
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.
super nit but I think the pattern seems to be to end the sentence with
.
as in the other changelog entries?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.
Fixed this and other changelog entries lacking the period in 7db4419.