diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 937c9d3..c123d9b 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -31,6 +31,8 @@ type Metrics struct { SubmissionDaHeight *prometheus.GaugeVec // BlockTime tracks the time between consecutive blocks with histogram buckets for accurate SLO calculations. BlockTime *prometheus.HistogramVec + // BlockTimeSummary tracks block time with percentiles over a rolling window. + BlockTimeSummary *prometheus.SummaryVec // BlockReceiveDelay tracks the delay between block creation and reception with histogram buckets. BlockReceiveDelay *prometheus.HistogramVec // JsonRpcRequestDuration tracks the duration of JSON-RPC requests to the EVM node. @@ -163,6 +165,22 @@ func NewWithRegistry(namespace string, registerer prometheus.Registerer) *Metric }, []string{"chain_id"}, ), + BlockTimeSummary: factory.NewSummaryVec( + prometheus.SummaryOpts{ + Namespace: namespace, + Name: "block_time_summary_seconds", + Help: "block time with percentiles over a 60-second rolling window", + Objectives: map[float64]float64{ + 0.5: 0.05, + 0.9: 0.01, + 0.95: 0.01, + 0.99: 0.001, + }, + MaxAge: 60 * time.Second, + AgeBuckets: 6, + }, + []string{"chain_id"}, + ), BlockReceiveDelay: factory.NewHistogramVec( prometheus.HistogramOpts{ Namespace: namespace, @@ -530,6 +548,7 @@ func (m *Metrics) RecordBlockTime(chainID string, arrivalTime time.Time) { // only record positive durations if blockTime > 0 { m.BlockTime.WithLabelValues(chainID).Observe(blockTime.Seconds()) + m.BlockTimeSummary.WithLabelValues(chainID).Observe(blockTime.Seconds()) } }