From 4c1224ed8056de6670cf42f7e778f5757341bcc1 Mon Sep 17 00:00:00 2001 From: Nicholas Pettas Date: Fri, 29 Mar 2024 16:54:34 -0700 Subject: [PATCH] add more metrics --- .gitignore | 1 + gossip/emitter/control.go | 12 ++++++++++++ gossip/emitter/emitter.go | 9 +++++++++ gossip/emitter/txs.go | 2 ++ 4 files changed, 24 insertions(+) diff --git a/.gitignore b/.gitignore index e6d8fa534..349a6477b 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,4 @@ testnet.g dist/ /docker/networksimulator/docker-compose.yaml /docker/networksimulator/prometheus/prometheus.yml +/docker/networksimulator/.env diff --git a/gossip/emitter/control.go b/gossip/emitter/control.go index 5feebeacf..82f33870f 100644 --- a/gossip/emitter/control.go +++ b/gossip/emitter/control.go @@ -1,6 +1,7 @@ package emitter import ( + "github.com/ethereum/go-ethereum/metrics" "time" "github.com/Fantom-foundation/lachesis-base/emitter/ancestor" @@ -11,6 +12,11 @@ import ( "github.com/Fantom-foundation/go-opera/inter" ) +var ( + allowedToEmitCount = metrics.GetOrRegisterGauge("opera/control/allowedToEmit", nil) + notAllowedToEmitCount = metrics.GetOrRegisterGauge("opera/control/notAllowedToEmit", nil) +) + func scalarUpdMetric(diff idx.Event, weight pos.Weight, totalWeight pos.Weight) ancestor.Metric { return ancestor.Metric(scalarUpdMetricF(uint64(diff)*piecefunc.DecimalUnit)) * ancestor.Metric(weight) / ancestor.Metric(totalWeight) } @@ -73,6 +79,7 @@ func (em *Emitter) isAllowedToEmit(e inter.EventI, eTxs bool, metric ancestor.Me "power", e.GasPowerLeft().String(), "selfParentPower", selfParent.GasPowerLeft().String(), "stake%", 100*float64(em.validators.Get(e.Creator()))/float64(em.validators.TotalWeight())) + notAllowedToEmitCount.Inc(1) return false } } @@ -87,6 +94,7 @@ func (em *Emitter) isAllowedToEmit(e inter.EventI, eTxs bool, metric ancestor.Me if passedTime >= em.intervals.Max || passedBlocks >= maxBlocks*4/5 && metric >= piecefunc.DecimalUnit/2 || passedBlocks >= maxBlocks { + allowedToEmitCount.Inc(1) return true } } @@ -109,6 +117,7 @@ func (em *Emitter) isAllowedToEmit(e inter.EventI, eTxs bool, metric ancestor.Me if passedTime < em.intervals.Max && em.idle() && !eTxs { + notAllowedToEmitCount.Inc(1) return false } } @@ -119,15 +128,18 @@ func (em *Emitter) isAllowedToEmit(e inter.EventI, eTxs bool, metric ancestor.Me } if adjustedPassedTime < em.intervals.Min && !em.idle() { + notAllowedToEmitCount.Inc(1) return false } if adjustedPassedIdleTime < em.intervals.Confirming && !em.idle() && !eTxs { + notAllowedToEmitCount.Inc(1) return false } } + allowedToEmitCount.Inc(1) return true } diff --git a/gossip/emitter/emitter.go b/gossip/emitter/emitter.go index 873ec200c..6a99b8f27 100644 --- a/gossip/emitter/emitter.go +++ b/gossip/emitter/emitter.go @@ -31,6 +31,9 @@ const ( ) var eventCounter = metrics.GetOrRegisterCounter("opera/events", nil) +var callCreatedCounter = metrics.GetOrRegisterCounter("opera/events/callCreated", nil) +var callEmitCounter = metrics.GetOrRegisterCounter("opera/events/callEmit", nil) +var worldBusyGauge = metrics.GetOrRegisterGauge("opera/events/worldBusy", nil) type Emitter struct { config Config @@ -189,7 +192,10 @@ func (em *Emitter) tick() { em.busyRate.Mark(1) } if em.world.IsBusy() { + worldBusyGauge.Update(1) return + } else { + worldBusyGauge.Update(0) } em.recheckChallenges() @@ -233,6 +239,8 @@ func (em *Emitter) EmitEvent() (*inter.EventPayload, error) { // short circuit if not a validator return nil, nil } + callEmitCounter.Inc(1) + sortedTxs := em.getSortedTxs() if em.world.IsBusy() { @@ -295,6 +303,7 @@ func (em *Emitter) createEvent(sortedTxs *types.TransactionsByPriceAndNonce) (*i if !em.isValidator() { return nil, nil } + callCreatedCounter.Inc(1) if synced := em.logSyncStatus(em.isSyncedToEmit()); !synced { // I'm reindexing my old events, so don't create events until connect all the existing self-events diff --git a/gossip/emitter/txs.go b/gossip/emitter/txs.go index 1fbed276a..7ba0df0d9 100644 --- a/gossip/emitter/txs.go +++ b/gossip/emitter/txs.go @@ -32,6 +32,7 @@ var ( isMyTurnCounter = metrics.GetOrRegisterCounter("opera/txs/isMyTurn", nil) isNotMyTurnCounter = metrics.GetOrRegisterCounter("opera/txs/isNotMyTurn", nil) outdatedCounter = metrics.GetOrRegisterCounter("opera/txs/outdated", nil) + invalidTxCounter = metrics.GetOrRegisterCounter("opera/txs/invalidTxCounter", nil) gasPowerUsedGauge = metrics.GetOrRegisterGauge("opera/txs/gasPowerUsed", nil) gasPowerLeftShortGauge = metrics.GetOrRegisterGauge("opera/txs/gasPowerLeftShort", nil) @@ -156,6 +157,7 @@ func (em *Emitter) addTxs(e *inter.MutableEventPayload, sorted *types.Transactio sender, _ := types.Sender(em.world.TxSigner, tx) // check transaction epoch rules if epochcheck.CheckTxs(types.Transactions{tx}, rules) != nil { + invalidTxCounter.Inc(1) sorted.Pop() continue }