mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
metrics: instrument request with histograms by default (#33921)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
This commit is contained in:
parent
8ec87250c1
commit
8254efc027
@ -60,7 +60,11 @@ func RequestMetrics(cfg *setting.Cfg) func(handler string) macaron.Handler {
|
||||
method := sanitizeMethod(req.Method)
|
||||
|
||||
// enable histogram and disable summaries + counters for http requests.
|
||||
if cfg.IsHTTPRequestHistogramEnabled() {
|
||||
if cfg.IsHTTPRequestHistogramDisabled() {
|
||||
duration := time.Since(now).Nanoseconds() / int64(time.Millisecond)
|
||||
metrics.MHttpRequestTotal.WithLabelValues(handler, code, method).Inc()
|
||||
metrics.MHttpRequestSummary.WithLabelValues(handler, code, method).Observe(float64(duration))
|
||||
} else {
|
||||
// avoiding the sanitize functions for in the new instrumentation
|
||||
// since they dont make much sense. We should remove them later.
|
||||
histogram := httpRequestDurationHistogram.
|
||||
@ -75,10 +79,6 @@ func RequestMetrics(cfg *setting.Cfg) func(handler string) macaron.Handler {
|
||||
return
|
||||
}
|
||||
histogram.Observe(time.Since(now).Seconds())
|
||||
} else {
|
||||
duration := time.Since(now).Nanoseconds() / int64(time.Millisecond)
|
||||
metrics.MHttpRequestTotal.WithLabelValues(handler, code, method).Inc()
|
||||
metrics.MHttpRequestSummary.WithLabelValues(handler, code, method).Observe(float64(duration))
|
||||
}
|
||||
|
||||
switch {
|
||||
|
@ -399,9 +399,11 @@ func (cfg Cfg) IsDatabaseMetricsEnabled() bool {
|
||||
return cfg.FeatureToggles["database_metrics"]
|
||||
}
|
||||
|
||||
// IsHTTPRequestHistogramEnabled returns whether the http_request_histogram feature is enabled.
|
||||
func (cfg Cfg) IsHTTPRequestHistogramEnabled() bool {
|
||||
return cfg.FeatureToggles["http_request_histogram"]
|
||||
// IsHTTPRequestHistogramDisabled returns whether the request historgrams is disabled.
|
||||
// This feature toggle will be removed in Grafana 8.x but gives the operator
|
||||
// some graceperiod to update all the monitoring tools.
|
||||
func (cfg Cfg) IsHTTPRequestHistogramDisabled() bool {
|
||||
return cfg.FeatureToggles["disable_http_request_histogram"]
|
||||
}
|
||||
|
||||
type CommandLineArgs struct {
|
||||
|
Loading…
Reference in New Issue
Block a user