Skip to content

Commit e60f757

Browse files
chore(reexecution/c): revert metervm metrics changes (#4397)
1 parent e752db2 commit e60f757

File tree

2 files changed

+26
-115
lines changed

2 files changed

+26
-115
lines changed

tests/reexecute/c/metrics.go

Lines changed: 0 additions & 105 deletions
This file was deleted.

tests/reexecute/c/vm_reexecute_test.go

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import (
4444
"github.com/ava-labs/avalanchego/utils/logging"
4545
"github.com/ava-labs/avalanchego/utils/timer"
4646
"github.com/ava-labs/avalanchego/utils/units"
47-
"github.com/ava-labs/avalanchego/vms/metervm"
4847
"github.com/ava-labs/avalanchego/vms/platformvm/warp"
4948
)
5049

@@ -176,9 +175,6 @@ func benchmarkReexecuteRange(
176175
vmMultiGatherer := metrics.NewPrefixGatherer()
177176
r.NoError(prefixGatherer.Register("avalanche_evm", vmMultiGatherer))
178177

179-
meterVMRegistry := prometheus.NewRegistry()
180-
r.NoError(prefixGatherer.Register("avalanche_meterchainvm", meterVMRegistry))
181-
182178
// consensusRegistry includes the chain="C" label and the prefix "avalanche_snowman".
183179
// The consensus registry is passed to the executor to mimic a subset of consensus metrics.
184180
consensusRegistry := prometheus.NewRegistry()
@@ -222,7 +218,6 @@ func benchmarkReexecuteRange(
222218
chainDataDir,
223219
configBytes,
224220
vmMultiGatherer,
225-
meterVMRegistry,
226221
)
227222
r.NoError(err)
228223
defer func() {
@@ -253,8 +248,7 @@ func newMainnetCChainVM(
253248
vmAndSharedMemoryDB database.Database,
254249
chainDataDir string,
255250
configBytes []byte,
256-
vmMultiGatherer metrics.MultiGatherer,
257-
meterVMRegistry prometheus.Registerer,
251+
metricsGatherer metrics.MultiGatherer,
258252
) (block.ChainVM, error) {
259253
factory := factory.Factory{}
260254
vmIntf, err := factory.New(logging.NoLog{})
@@ -282,8 +276,6 @@ func newMainnetCChainVM(
282276
ids.Empty: constants.PrimaryNetworkID,
283277
}
284278

285-
vm = metervm.NewBlockVM(vm, meterVMRegistry)
286-
287279
if err := vm.Initialize(
288280
ctx,
289281
&snow.Context{
@@ -301,7 +293,7 @@ func newMainnetCChainVM(
301293
Log: tests.NewDefaultLogger("mainnet-vm-reexecution"),
302294
SharedMemory: atomicMemory.NewSharedMemory(mainnetCChainID),
303295
BCLookup: ids.NewAliaser(),
304-
Metrics: vmMultiGatherer,
296+
Metrics: metricsGatherer,
305297

306298
WarpSigner: warpSigner,
307299

@@ -625,3 +617,27 @@ func parseCustomLabels(labelsStr string) (map[string]string, error) {
625617
}
626618
return labels, nil
627619
}
620+
621+
func getTopLevelMetrics(b *testing.B, registry prometheus.Gatherer, elapsed time.Duration) {
622+
r := require.New(b)
623+
624+
gasUsed, err := getCounterMetricValue(registry, "avalanche_evm_eth_chain_block_gas_used_processed")
625+
r.NoError(err)
626+
mgasPerSecond := gasUsed / 1_000_000 / elapsed.Seconds()
627+
b.ReportMetric(mgasPerSecond, "mgas/s")
628+
}
629+
630+
func getCounterMetricValue(registry prometheus.Gatherer, query string) (float64, error) {
631+
metricFamilies, err := registry.Gather()
632+
if err != nil {
633+
return 0, fmt.Errorf("failed to gather metrics: %w", err)
634+
}
635+
636+
for _, mf := range metricFamilies {
637+
if mf.GetName() == query {
638+
return mf.GetMetric()[0].Counter.GetValue(), nil
639+
}
640+
}
641+
642+
return 0, fmt.Errorf("metric %s not found", query)
643+
}

0 commit comments

Comments
 (0)