2016-09-28 11:35:15 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
2020-11-11 17:59:12 +00:00
|
|
|
"github.com/fleetdm/fleet/server/kolide"
|
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 {
|
|
|
|
kolide.Service
|
|
|
|
requestCount metrics.Counter
|
|
|
|
requestLatency metrics.Histogram
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewMetrics service takes an existing service and wraps it
|
|
|
|
// with instrumentation middleware.
|
|
|
|
func NewMetricsService(
|
|
|
|
svc kolide.Service,
|
|
|
|
requestCount metrics.Counter,
|
|
|
|
requestLatency metrics.Histogram,
|
|
|
|
) kolide.Service {
|
|
|
|
return metricsMiddleware{
|
|
|
|
Service: svc,
|
|
|
|
requestCount: requestCount,
|
|
|
|
requestLatency: requestLatency,
|
|
|
|
}
|
|
|
|
}
|