mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
This is a preparation to introduce an httpclient common package. And it makes it easier to use http from the standard library.
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
// SPDX-FileCopyrightText: 2022 Free Mobile
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
package httpserver
|
|
|
|
import "akvorado/common/reporter"
|
|
|
|
type metrics struct {
|
|
inflights reporter.Gauge
|
|
requests *reporter.CounterVec
|
|
durations *reporter.HistogramVec
|
|
sizes *reporter.HistogramVec
|
|
cacheHit *reporter.CounterVec
|
|
cacheMiss *reporter.CounterVec
|
|
}
|
|
|
|
func (c *Component) initMetrics() {
|
|
c.metrics.inflights = c.r.Gauge(
|
|
reporter.GaugeOpts{
|
|
Name: "inflight_requests",
|
|
Help: "Number of requests currently being served by the HTTP server.",
|
|
},
|
|
)
|
|
c.metrics.requests = c.r.CounterVec(
|
|
reporter.CounterOpts{
|
|
Name: "requests_total",
|
|
Help: "Number of requests handled by an handler.",
|
|
}, []string{"handler", "code", "method"},
|
|
)
|
|
c.metrics.durations = c.r.HistogramVec(
|
|
reporter.HistogramOpts{
|
|
Name: "request_duration_seconds",
|
|
Help: "Latencies for served requests.",
|
|
Buckets: []float64{.25, .5, 1, 2.5, 5, 10},
|
|
}, []string{"handler", "method"},
|
|
)
|
|
c.metrics.sizes = c.r.HistogramVec(
|
|
reporter.HistogramOpts{
|
|
Name: "response_size_bytes",
|
|
Help: "Response sizes for requests.",
|
|
Buckets: []float64{200, 500, 1000, 1500, 5000},
|
|
}, []string{"handler", "method"},
|
|
)
|
|
c.metrics.cacheHit = c.r.CounterVec(
|
|
reporter.CounterOpts{
|
|
Name: "cache_hit_total",
|
|
Help: "Number of requests served from cache",
|
|
}, []string{"path", "method"},
|
|
)
|
|
c.metrics.cacheMiss = c.r.CounterVec(
|
|
reporter.CounterOpts{
|
|
Name: "cache_miss_total",
|
|
Help: "Number of requests not served from cache",
|
|
}, []string{"path", "method"},
|
|
)
|
|
}
|