fleet/server/service/metrics.go
WangXiang 468754f2b9
Format and clean code (#774)
1. use [staticcheck](https://staticcheck.io/) to check the code, and fix some issues.
2. use `go fmt` to format the code.
3. use `go mod tidy` clean the go mod.
2021-05-17 10:29:50 -07:00

27 lines
569 B
Go

package service
import (
"github.com/fleetdm/fleet/server/kolide"
"github.com/go-kit/kit/metrics"
)
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,
}
}