Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing prometheus metrics #219

Merged
merged 2 commits into from
Oct 8, 2024
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
9 changes: 9 additions & 0 deletions config/make_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"github.com/ethereum/go-ethereum/accounts/external"
"github.com/ethereum/go-ethereum/accounts/scwallet"
"github.com/ethereum/go-ethereum/accounts/usbwallet"
"github.com/ethereum/go-ethereum/metrics"
"path"
"strconv"
"time"

"github.com/Fantom-foundation/go-opera/config/flags"
Expand All @@ -23,6 +25,10 @@ import (
"gopkg.in/urfave/cli.v1"
)

var (
chainInfoGauge = metrics.GetOrRegisterGaugeInfo("chain/info", nil)
)

func MakeNode(ctx *cli.Context, cfg *Config) (*node.Node, *gossip.Service, func(), error) {
var success bool
var cleanup []func()
Expand Down Expand Up @@ -150,6 +156,9 @@ func MakeNode(ctx *cli.Context, cfg *Config) (*node.Node, *gossip.Service, func(
stack.RegisterProtocols(svc.Protocols())
stack.RegisterLifecycle(svc)

rules, _ := gdb.GetEpochRules()
chainInfoGauge.Update(metrics.GaugeInfoValue{"chain_id": strconv.FormatUint(rules.NetworkID, 10)})

success = true // skip cleanup in defer - keep it for the returned cleanup function
return stack, svc, func() {
for i := len(cleanup) - 1; i >= 0; i-- {
Expand Down
5 changes: 4 additions & 1 deletion gossip/c_block_callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
headFastBlockGauge = metrics.GetOrRegisterGauge("chain/head/receipt", nil)

blockExecutionTimer = metrics.GetOrRegisterResettingTimer("chain/execution", nil)
blockExecutionNonResettingTimer = metrics.GetOrRegisterTimer("chain/execution/nonresetting", nil)
blockAgeGauge = metrics.GetOrRegisterGauge("chain/block/age", nil)

processedTxsMeter = metrics.GetOrRegisterMeter("chain/txs/processed", nil)
Expand Down Expand Up @@ -313,7 +314,9 @@ func consensusCallbackBeginBlockFn(
store.EvmStore().SetCachedEvmBlock(blockCtx.Idx, evmBlock)

// Update the metrics touched during block processing
blockExecutionTimer.Update(time.Since(executionStart))
executionTime := time.Since(executionStart)
blockExecutionTimer.Update(executionTime)
blockExecutionNonResettingTimer.Update(executionTime)

// Update the metrics touched by new block
headBlockGauge.Update(int64(blockCtx.Idx))
Expand Down
Loading