Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion metrics/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,20 @@ var gasEstimationIterations = prometheus.NewGauge(prometheus.GaugeOpts{
Help: "Number of iterations taken to estimate the gas of a EVM call/tx",
})

// Time difference between block proposal time and block indexing time
var blockIngestionTime = prometheus.NewHistogram(prometheus.HistogramOpts{
Name: prefixedName("block_ingestion_time_seconds"),
Help: "Time taken to fully ingest an EVM block in the local state index",
Help: "Latency from EVM block proposal time to indexing completion (wall-clock duration)",
Buckets: []float64{.5, 1, 2.5, 5, 10, 15, 20, 30, 45},
})

// EVM block processing time during event ingestion, including transaction replay
// and state validation
var blockProcessTime = prometheus.NewSummary(prometheus.SummaryOpts{
Name: prefixedName("block_process_time_seconds"),
Help: "Processing time to fully index an EVM block in the local state index",
})
Comment thread
coderabbitai[bot] marked this conversation as resolved.

var requestRateLimitedCounters = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: prefixedName("request_rate_limited"),
Help: "Total number of rate limits by JSON-RPC method",
Expand Down Expand Up @@ -105,6 +113,7 @@ var metrics = []prometheus.Collector{
availableSigningKeys,
gasEstimationIterations,
blockIngestionTime,
blockProcessTime,
requestRateLimitedCounters,
transactionsDroppedCounter,
rateLimitedTransactionsCounter,
Expand All @@ -123,6 +132,7 @@ type Collector interface {
AvailableSigningKeys(count int)
GasEstimationIterations(count int)
BlockIngestionTime(blockCreation time.Time)
BlockProcessTime(start time.Time)
RequestRateLimited(method string)
TransactionsDropped(count int)
TransactionRateLimited()
Expand All @@ -147,6 +157,7 @@ type DefaultCollector struct {
availableSigningkeys prometheus.Gauge
gasEstimationIterations prometheus.Gauge
blockIngestionTime prometheus.Histogram
blockProcessTime prometheus.Summary
requestRateLimitedCounters *prometheus.CounterVec
transactionsDroppedCounter prometheus.Counter
rateLimitedTransactionsCounter prometheus.Counter
Expand All @@ -173,6 +184,7 @@ func NewCollector(logger zerolog.Logger) Collector {
availableSigningkeys: availableSigningKeys,
gasEstimationIterations: gasEstimationIterations,
blockIngestionTime: blockIngestionTime,
blockProcessTime: blockProcessTime,
requestRateLimitedCounters: requestRateLimitedCounters,
transactionsDroppedCounter: transactionsDroppedCounter,
rateLimitedTransactionsCounter: rateLimitedTransactionsCounter,
Expand Down Expand Up @@ -243,6 +255,10 @@ func (c *DefaultCollector) BlockIngestionTime(blockCreation time.Time) {
Observe(time.Since(blockCreation).Seconds())
}

func (c *DefaultCollector) BlockProcessTime(start time.Time) {
c.blockProcessTime.Observe(time.Since(start).Seconds())
}

func (c *DefaultCollector) RequestRateLimited(method string) {
c.requestRateLimitedCounters.With(
prometheus.Labels{
Expand Down
1 change: 1 addition & 0 deletions metrics/nop.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (c *nopCollector) OperatorBalance(balance uint64) {}
func (c *nopCollector) AvailableSigningKeys(count int) {}
func (c *nopCollector) GasEstimationIterations(count int) {}
func (c *nopCollector) BlockIngestionTime(blockCreation time.Time) {}
func (c *nopCollector) BlockProcessTime(start time.Time) {}
func (c *nopCollector) RequestRateLimited(method string) {}
func (c *nopCollector) TransactionsDropped(count int) {}
func (c *nopCollector) TransactionRateLimited() {}
Expand Down
3 changes: 3 additions & 0 deletions services/ingestion/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,14 @@ func (e *Engine) processEvents(events *models.CadenceEvents) error {
Int("cadence-event-length", events.Length()).
Msg("received new cadence evm events")

start := time.Now()
err := e.withBatch(
func(batch *pebbleDB.Batch) error {
return e.indexEvents(events, batch)
},
)
e.collector.BlockProcessTime(start)

if err != nil {
return fmt.Errorf("failed to index events for cadence block %d: %w", events.CadenceHeight(), err)
}
Expand Down
Loading