-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4801 from onflow/petera/4798-add-indexer-metrics
[Access] Add metrics to execution state indexer
- Loading branch information
Showing
7 changed files
with
184 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package metrics | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
|
||
"github.com/onflow/flow-go/module" | ||
) | ||
|
||
var _ module.ExecutionStateIndexerMetrics = (*ExecutionStateIndexerCollector)(nil) | ||
|
||
type ExecutionStateIndexerCollector struct { | ||
indexDuration prometheus.Histogram | ||
highestIndexedHeight prometheus.Gauge | ||
|
||
indexedEvents prometheus.Counter | ||
indexedRegisters prometheus.Counter | ||
indexedTransactionResults prometheus.Counter | ||
reindexedHeightCount prometheus.Counter | ||
} | ||
|
||
func NewExecutionStateIndexerCollector() module.ExecutionStateIndexerMetrics { | ||
indexDuration := promauto.NewHistogram(prometheus.HistogramOpts{ | ||
Namespace: namespaceAccess, | ||
Subsystem: subsystemExecutionStateIndexer, | ||
Name: "index_duration_ms", | ||
Help: "the duration of execution state indexing operation", | ||
Buckets: []float64{1, 5, 10, 50, 100}, | ||
}) | ||
|
||
highestIndexedHeight := promauto.NewGauge(prometheus.GaugeOpts{ | ||
Namespace: namespaceAccess, | ||
Subsystem: subsystemExecutionStateIndexer, | ||
Name: "highest_indexed_height", | ||
Help: "highest block height that has been indexed", | ||
}) | ||
|
||
indexedEvents := promauto.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespaceAccess, | ||
Subsystem: subsystemExecutionStateIndexer, | ||
Name: "indexed_events", | ||
Help: "number of events indexed", | ||
}) | ||
|
||
indexedRegisters := promauto.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespaceAccess, | ||
Subsystem: subsystemExecutionStateIndexer, | ||
Name: "indexed_registers", | ||
Help: "number of registers indexed", | ||
}) | ||
|
||
indexedTransactionResults := promauto.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespaceAccess, | ||
Subsystem: subsystemExecutionStateIndexer, | ||
Name: "indexed_transaction_results", | ||
Help: "number of transaction results indexed", | ||
}) | ||
|
||
reindexedHeightCount := promauto.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespaceAccess, | ||
Subsystem: subsystemExecutionStateIndexer, | ||
Name: "reindexed_height_count", | ||
Help: "number of times a previously indexed height is reindexed", | ||
}) | ||
|
||
return &ExecutionStateIndexerCollector{ | ||
indexDuration: indexDuration, | ||
highestIndexedHeight: highestIndexedHeight, | ||
indexedEvents: indexedEvents, | ||
indexedRegisters: indexedRegisters, | ||
indexedTransactionResults: indexedTransactionResults, | ||
reindexedHeightCount: reindexedHeightCount, | ||
} | ||
} | ||
|
||
// BlockIndexed records metrics from indexing execution data from a single block. | ||
func (c *ExecutionStateIndexerCollector) BlockIndexed(height uint64, duration time.Duration, registers, events, transactionResults int) { | ||
c.indexDuration.Observe(float64(duration.Milliseconds())) | ||
c.highestIndexedHeight.Set(float64(height)) | ||
c.indexedEvents.Add(float64(events)) | ||
c.indexedRegisters.Add(float64(registers)) | ||
c.indexedTransactionResults.Add(float64(transactionResults)) | ||
} | ||
|
||
// BlockReindexed records that a previously indexed block was indexed again. | ||
func (c *ExecutionStateIndexerCollector) BlockReindexed() { | ||
c.reindexedHeightCount.Inc() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.