Skip to content

Commit 3d43ebb

Browse files
committed
Add scheduled transaction metrics
1 parent 4de3080 commit 3d43ebb

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

engine/execution/computation/computer/computer.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,21 @@ func (e *blockComputer) executeProcessCallback(
650650
return nil, 0, err
651651
}
652652

653+
if len(callbackTxs) > 0 {
654+
// calculate total gas limits for execute callback transactions
655+
var totalExecuteGasLimits uint64
656+
for _, tx := range callbackTxs {
657+
totalExecuteGasLimits += tx.GasLimit
658+
}
659+
660+
// report metrics for callbacks executed
661+
e.metrics.ExecutionCallbacksExecuted(
662+
len(callbackTxs),
663+
txn.Output().ComputationUsed,
664+
totalExecuteGasLimits,
665+
)
666+
}
667+
653668
return callbackTxs, txnIndex, nil
654669
}
655670

module/metrics.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,9 @@ type ExecutionMetrics interface {
10271027
// ExecutionScriptExecuted reports the time and memory spent on executing an script
10281028
ExecutionScriptExecuted(dur time.Duration, compUsed, memoryUsed, memoryEstimate uint64)
10291029

1030+
// ExecutionCallbacksExecuted reports the number of callbacks executed, gas used by process transaction, and total gas limits for execute transactions
1031+
ExecutionCallbacksExecuted(callbackCount int, processGasUsed, executeGasLimits uint64)
1032+
10301033
// ExecutionCollectionRequestSent reports when a request for a collection is sent to a collection node
10311034
ExecutionCollectionRequestSent()
10321035

module/metrics/execution.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ type ExecutionCollector struct {
9898
evmTransactionGasUsed prometheus.Histogram
9999
evmBlockTxCount prometheus.Histogram
100100
evmBlockGasUsed prometheus.Histogram
101+
callbacksExecutedCount prometheus.Histogram
102+
callbacksProcessGasUsed prometheus.Histogram
103+
callbacksExecuteGasLimits prometheus.Histogram
101104
}
102105

103106
func NewExecutionCollector(tracer module.Tracer) *ExecutionCollector {
@@ -793,6 +796,30 @@ func NewExecutionCollector(tracer module.Tracer) *ExecutionCollector {
793796
Name: "evm_block_total_supply",
794797
Help: "the total amount of flow deposited to EVM (in FLOW)",
795798
}),
799+
800+
callbacksExecutedCount: promauto.NewHistogram(prometheus.HistogramOpts{
801+
Namespace: namespaceExecution,
802+
Subsystem: subsystemRuntime,
803+
Name: "callbacks_executed_count",
804+
Help: "the number of callbacks executed",
805+
Buckets: prometheus.ExponentialBuckets(1, 2, 8),
806+
}),
807+
808+
callbacksProcessGasUsed: promauto.NewHistogram(prometheus.HistogramOpts{
809+
Namespace: namespaceExecution,
810+
Subsystem: subsystemRuntime,
811+
Name: "callbacks_process_gas_used",
812+
Help: "the gas used by the process callback transaction",
813+
Buckets: prometheus.ExponentialBuckets(10_000, 2, 12),
814+
}),
815+
816+
callbacksExecuteGasLimits: promauto.NewHistogram(prometheus.HistogramOpts{
817+
Namespace: namespaceExecution,
818+
Subsystem: subsystemRuntime,
819+
Name: "callbacks_execute_gas_limits",
820+
Help: "the total gas limits for execute callback transactions",
821+
Buckets: prometheus.ExponentialBuckets(10_000, 2, 12),
822+
}),
796823
}
797824

798825
return ec
@@ -883,6 +910,13 @@ func (ec *ExecutionCollector) ExecutionScriptExecuted(dur time.Duration, compUse
883910
ec.scriptMemoryDifference.Observe(float64(memoryEstimated) - float64(memoryUsed))
884911
}
885912

913+
// ExecutionCallbacksExecuted reports callback execution metrics
914+
func (ec *ExecutionCollector) ExecutionCallbacksExecuted(callbackCount int, processGasUsed, executeGasLimits uint64) {
915+
ec.callbacksExecutedCount.Observe(float64(callbackCount))
916+
ec.callbacksProcessGasUsed.Observe(float64(processGasUsed))
917+
ec.callbacksExecuteGasLimits.Observe(float64(executeGasLimits))
918+
}
919+
886920
// ExecutionStateStorageDiskTotal reports the total storage size of the execution state on disk in bytes
887921
func (ec *ExecutionCollector) ExecutionStateStorageDiskTotal(bytes int64) {
888922
ec.stateStorageDiskTotal.Set(float64(bytes))

module/metrics/noop.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ func (nc *NoopCollector) ExecutionTransactionExecuted(_ time.Duration, _ module.
181181
}
182182
func (nc *NoopCollector) ExecutionChunkDataPackGenerated(_, _ int) {}
183183
func (nc *NoopCollector) ExecutionScriptExecuted(dur time.Duration, compUsed, _, _ uint64) {}
184+
func (nc *NoopCollector) ExecutionCallbacksExecuted(int, uint64, uint64) {}
184185
func (nc *NoopCollector) ForestApproxMemorySize(bytes uint64) {}
185186
func (nc *NoopCollector) ForestNumberOfTrees(number uint64) {}
186187
func (nc *NoopCollector) LatestTrieRegCount(number uint64) {}

module/mock/execution_metrics.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)