Skip to content

Commit

Permalink
feat: adds metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
ckartik committed Jul 2, 2024
1 parent 7d69f1f commit 5e6e9e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions oracle/pkg/updater/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type metrics struct {
BlockTimeCacheHits prometheus.Counter
BlockTimeCacheMisses prometheus.Counter
LastSentNonce prometheus.Gauge
TxnReceiptRequestDuration prometheus.Histogram
}

func newMetrics() *metrics {
Expand Down Expand Up @@ -129,6 +130,14 @@ func newMetrics() *metrics {
Help: "Last nonce sent to for settlement",
},
)
m.TxnReceiptRequestDuration = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: defaultNamespace,
Subsystem: subsystem,
Name: "txn_receipt_request_duration",
Help: "Duration of transaction receipt requests",
},
)
return m
}

Expand Down
3 changes: 3 additions & 0 deletions oracle/pkg/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strings"
"sync"
"sync/atomic"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -498,10 +499,12 @@ func (u *Updater) getL1Txns(ctx context.Context, blockNum uint64) (map[string]Tx

for _, bucket := range buckets {
eg.Go(func() error {
start := time.Now()
results, err := u.receiptBatcher.BatchReceipts(ctx, bucket)
if err != nil {
return fmt.Errorf("failed to get batch receipts: %w", err)
}
u.metrics.TxnReceiptRequestDuration.Observe(time.Since(start).Seconds())
for _, result := range results {
if result.Err != nil {
return fmt.Errorf("failed to get receipt for txn: %s", result.Err)
Expand Down

0 comments on commit 5e6e9e6

Please sign in to comment.