Skip to content

Commit

Permalink
feat: get total duration for block receipts
Browse files Browse the repository at this point in the history
  • Loading branch information
ckartik committed Jul 4, 2024
1 parent 0d2044e commit faa49ce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
38 changes: 24 additions & 14 deletions oracle/pkg/updater/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand All @@ -157,5 +166,6 @@ func (m *metrics) Collectors() []prometheus.Collector {
m.BlockTimeCacheMisses,
m.LastSentNonce,
m.TxnReceiptRequestDuration,
m.TxnReceiptRequestBlockDuration,
}
}
4 changes: 4 additions & 0 deletions oracle/pkg/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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())
Expand Down

0 comments on commit faa49ce

Please sign in to comment.