Skip to content

Commit

Permalink
Reduce the operator latency metric cardinality (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix authored Sep 20, 2024
1 parent 45f6941 commit 8c6617f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions disperser/batcher/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ type FinalizerMetrics struct {
}

type DispatcherMetrics struct {
Latency *prometheus.SummaryVec
Latency *prometheus.SummaryVec
OperatorLatency *prometheus.GaugeVec
}

type Metrics struct {
Expand Down Expand Up @@ -178,6 +179,14 @@ func NewMetrics(httpPort string, logger logging.Logger) *Metrics {
},
[]string{"operator_id", "status"},
),
OperatorLatency: promauto.With(reg).NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "operator_attestation_latency_ms",
Help: "attestation latency in ms observed for operators",
},
[]string{"operator_id"},
),
}

metrics := &Metrics{
Expand Down Expand Up @@ -288,7 +297,14 @@ func (t *DispatcherMetrics) ObserveLatency(operatorId string, success bool, late
if !success {
label = "failure"
}
t.Latency.WithLabelValues(operatorId, label).Observe(latencyMS)
// The Latency metric has "operator_id" but we null it out because it's separately
// tracked in OperatorLatency.
t.Latency.WithLabelValues("", label).Observe(latencyMS)
// Only tracks successful requests, so there is one stream per operator.
// This is sufficient to provide insights of operators' performance.
if success {
t.OperatorLatency.WithLabelValues(operatorId).Set(latencyMS)
}
}

// UpdateCompletedBlob increments the number and updates size of processed blobs.
Expand Down

0 comments on commit 8c6617f

Please sign in to comment.