2016-09-28 11:35:15 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
2021-06-26 04:46:51 +00:00
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
2021-05-17 17:29:50 +00:00
|
|
|
"github.com/go-kit/kit/metrics"
|
2016-09-28 11:35:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type metricsMiddleware struct {
|
2021-06-06 22:07:29 +00:00
|
|
|
fleet.Service
|
2016-09-28 11:35:15 +00:00
|
|
|
requestCount metrics.Counter
|
|
|
|
requestLatency metrics.Histogram
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewMetrics service takes an existing service and wraps it
|
|
|
|
// with instrumentation middleware.
|
|
|
|
func NewMetricsService(
|
2021-06-06 22:07:29 +00:00
|
|
|
svc fleet.Service,
|
2016-09-28 11:35:15 +00:00
|
|
|
requestCount metrics.Counter,
|
|
|
|
requestLatency metrics.Histogram,
|
2021-06-06 22:07:29 +00:00
|
|
|
) fleet.Service {
|
2016-09-28 11:35:15 +00:00
|
|
|
return metricsMiddleware{
|
|
|
|
Service: svc,
|
|
|
|
requestCount: requestCount,
|
|
|
|
requestLatency: requestLatency,
|
|
|
|
}
|
|
|
|
}
|