add more sync stages to metrics (#5740)

hi! 

this pr adds more sync stages to the prometheus metrics. node now shows 

```
sync{stage="account_history_index"} 15742138
sync{stage="block_hashes"} 15742138
sync{stage="bodies"} 15742138
sync{stage="call_traces"} 15742138
sync{stage="cumulative_index"} 15742138
sync{stage="execution"} 15742138
sync{stage="finish"} 15742138
sync{stage="hash_state"} 15742138
sync{stage="headers"} 15742138
sync{stage="intermediate_hashes"} 15742138
sync{stage="log_index"} 15742138
sync{stage="senders"} 15742138
sync{stage="snapshots"} 15742138
sync{stage="storage_history_index"} 15742138
sync{stage="translation"} 0
sync{stage="tx_lookup"} 15742138
sync{stage="verkle_trie"} 0
sync{stage="watch_the_burn"} 0
```

Co-authored-by: a <a@a.a>
This commit is contained in:
gfx 2022-10-17 22:22:57 -05:00 committed by GitHub
parent 3aa97c57c1
commit d1e9149c93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,15 +1,25 @@
package stagedsync
import (
"fmt"
"github.com/VictoriaMetrics/metrics"
"github.com/huandu/xstrings"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/eth/stagedsync/stages"
)
var syncMetrics = map[stages.SyncStage]*metrics.Counter{
stages.Headers: metrics.GetOrCreateCounter(`sync{stage="headers"}`),
stages.Execution: metrics.GetOrCreateCounter(`sync{stage="execution"}`),
stages.Finish: metrics.GetOrCreateCounter(`sync{stage="finish"}`),
var syncMetrics = map[stages.SyncStage]*metrics.Counter{}
func init() {
for _, v := range stages.AllStages {
syncMetrics[v] = metrics.GetOrCreateCounter(
fmt.Sprintf(
`sync{stage="%s"}`,
xstrings.ToSnakeCase(string(v)),
),
)
}
}
// UpdateMetrics - need update metrics manually because current "metrics" package doesn't support labels