From faa49cede064df34e492d337e9bccc2983502734 Mon Sep 17 00:00:00 2001 From: Kartik Chopra Date: Wed, 3 Jul 2024 13:05:56 -0400 Subject: [PATCH] feat: get total duration for block receipts --- oracle/pkg/updater/metrics.go | 38 ++++++++++++++++++++++------------- oracle/pkg/updater/updater.go | 4 ++++ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/oracle/pkg/updater/metrics.go b/oracle/pkg/updater/metrics.go index ff3557655..46363c5b5 100644 --- a/oracle/pkg/updater/metrics.go +++ b/oracle/pkg/updater/metrics.go @@ -8,20 +8,21 @@ const ( ) type metrics struct { - CommitmentsReceivedCount prometheus.Counter - CommitmentsProcessedCount prometheus.Counter - CommitmentsTooOldCount prometheus.Counter - DuplicateCommitmentsCount prometheus.Counter - RewardsCount prometheus.Counter - SlashesCount prometheus.Counter - EncryptedCommitmentsCount prometheus.Counter - NoWinnerCount prometheus.Counter - BlockTxnCacheHits prometheus.Counter - BlockTxnCacheMisses prometheus.Counter - BlockTimeCacheHits prometheus.Counter - BlockTimeCacheMisses prometheus.Counter - LastSentNonce prometheus.Gauge - TxnReceiptRequestDuration prometheus.Histogram + CommitmentsReceivedCount prometheus.Counter + CommitmentsProcessedCount prometheus.Counter + CommitmentsTooOldCount prometheus.Counter + DuplicateCommitmentsCount prometheus.Counter + RewardsCount prometheus.Counter + SlashesCount prometheus.Counter + EncryptedCommitmentsCount prometheus.Counter + NoWinnerCount prometheus.Counter + BlockTxnCacheHits prometheus.Counter + BlockTxnCacheMisses prometheus.Counter + BlockTimeCacheHits prometheus.Counter + BlockTimeCacheMisses prometheus.Counter + LastSentNonce prometheus.Gauge + TxnReceiptRequestDuration prometheus.Histogram + TxnReceiptRequestBlockDuration prometheus.Histogram } func newMetrics() *metrics { @@ -138,6 +139,14 @@ func newMetrics() *metrics { Help: "Duration of transaction receipt requests", }, ) + m.TxnReceiptRequestBlockDuration = prometheus.NewHistogram( + prometheus.HistogramOpts{ + Namespace: defaultNamespace, + Subsystem: subsystem, + Name: "txn_receipt_request_block_duration", + Help: "Duration of transaction receipt requests", + }, + ) return m } @@ -157,5 +166,6 @@ func (m *metrics) Collectors() []prometheus.Collector { m.BlockTimeCacheMisses, m.LastSentNonce, m.TxnReceiptRequestDuration, + m.TxnReceiptRequestBlockDuration, } } diff --git a/oracle/pkg/updater/updater.go b/oracle/pkg/updater/updater.go index 893e18e3a..3ab8cbd7c 100644 --- a/oracle/pkg/updater/updater.go +++ b/oracle/pkg/updater/updater.go @@ -497,6 +497,8 @@ func (u *Updater) getL1Txns(ctx context.Context, blockNum uint64) (map[string]Tx buckets[i] = txnsArray[start:end] } + blockStart := time.Now() + for _, bucket := range buckets { eg.Go(func() error { start := time.Now() @@ -521,6 +523,8 @@ func (u *Updater) getL1Txns(ctx context.Context, blockNum uint64) (map[string]Tx return nil, err } + u.metrics.TxnReceiptRequestBlockDuration.Observe(time.Since(blockStart).Seconds()) + txnsMap := make(map[string]TxMetadata) for i, tx := range txnsArray { receipt, ok := txnReceipts.Load(tx.Hex())