Skip to content

Commit

Permalink
Cleanup metrics; closes #128
Browse files Browse the repository at this point in the history
  • Loading branch information
gagliardetto committed Jul 11, 2024
1 parent fc8ae64 commit b44d015
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions http-range.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (r *readCloserWrapper) ReadAt(p []byte, off int64) (n int, err error) {
indexName = byDot[len(byDot)-1]
}
// TODO: distinguish between remote and local index reads
metrics.IndexLookups.WithLabelValues(indexName).Observe(float64(took.Seconds()))
metrics.IndexLookupHistogram.WithLabelValues(indexName).Observe(float64(took.Seconds()))
}
// if has suffix .car, then it's a car file
if strings.HasSuffix(r.name, ".car") || r.isSplitCar {
Expand All @@ -64,7 +64,7 @@ func (r *readCloserWrapper) ReadAt(p []byte, off int64) (n int, err error) {
}
carName := filepath.Base(r.name)
// TODO: distinguish between remote and local index reads
metrics.CarLookups.WithLabelValues(carName).Observe(float64(took.Seconds()))
metrics.CarLookupHistogram.WithLabelValues(carName).Observe(float64(took.Seconds()))
}
klog.V(5).Infof(prefix+" %s:%d+%d (%s)\n", (r.name), off, len(p), took)
}
Expand Down
29 changes: 15 additions & 14 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ var MethodToNumProxied = promauto.NewCounterVec(
[]string{"method"},
)

var ResponseTimeHistogram = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Name: "response_time_histogram",
Help: "Response time histogram",
},
[]string{"method"},
)

// - Version information of this binary
var Version = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Expand All @@ -70,20 +62,29 @@ var Version = promauto.NewGaugeVec(
[]string{"started_at", "tag", "commit", "compiler", "goarch", "goos", "goamd64", "vcs", "vcs_revision", "vcs_time", "vcs_modified"},
)

var IndexLookups = promauto.NewHistogramVec(
var IndexLookupHistogram = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Name: "index_lookups",
Help: "Index lookups",
Name: "index_lookup_latency_histogram",
Help: "Index lookup latency",
Buckets: prometheus.ExponentialBuckets(0.000001, 10, 10),
},
[]string{"index_type"},
)

var CarLookups = promauto.NewHistogramVec(
var CarLookupHistogram = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Name: "car_lookups",
Help: "Car lookups",
Name: "car_lookup_latency_histogram",
Help: "Car lookup latency",
Buckets: prometheus.ExponentialBuckets(0.000001, 10, 10),
},
[]string{"car"},
)

var RpcResponseLatencyHistogram = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Name: "rpc_response_latency_histogram",
Help: "RPC response latency histogram",
Buckets: prometheus.ExponentialBuckets(0.000001, 10, 10),
},
[]string{"rpc_method"},
)
5 changes: 3 additions & 2 deletions multiepoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,10 @@ func newMultiEpochHandler(handler *MultiEpoch, lsConf *ListenerConfig) func(ctx
if method == "/metrics" || method == "/health" {
return
}
klog.V(2).Infof("[%s] request %q took %s", reqID, sanitizeMethod(method), time.Since(startedAt))
took := time.Since(startedAt)
klog.V(2).Infof("[%s] request %q took %s", reqID, sanitizeMethod(method), took)
metrics.StatusCode.WithLabelValues(fmt.Sprint(reqCtx.Response.StatusCode())).Inc()
metrics.ResponseTimeHistogram.WithLabelValues(sanitizeMethod(method)).Observe(time.Since(startedAt).Seconds())
metrics.RpcResponseLatencyHistogram.WithLabelValues(sanitizeMethod(method)).Observe(took.Seconds())
}()
{
// handle the /metrics endpoint
Expand Down

0 comments on commit b44d015

Please sign in to comment.