From 35579dfa938562969da2395492f4472c300574dd Mon Sep 17 00:00:00 2001 From: David Date: Tue, 1 Oct 2024 01:13:31 +0800 Subject: [PATCH] feat(taiko-client): add `proposer_pool_content_fetch_time` metric (#18190) --- packages/taiko-client/internal/metrics/metrics.go | 1 + packages/taiko-client/proposer/proposer.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/taiko-client/internal/metrics/metrics.go b/packages/taiko-client/internal/metrics/metrics.go index 1c27e5d9419..44de2709188 100644 --- a/packages/taiko-client/internal/metrics/metrics.go +++ b/packages/taiko-client/internal/metrics/metrics.go @@ -29,6 +29,7 @@ var ( ProposerProposeEpochCounter = factory.NewCounter(prometheus.CounterOpts{Name: "proposer_epoch"}) ProposerProposedTxListsCounter = factory.NewCounter(prometheus.CounterOpts{Name: "proposer_proposed_txLists"}) ProposerProposedTxsCounter = factory.NewCounter(prometheus.CounterOpts{Name: "proposer_proposed_txs"}) + ProposerPoolContentFetchTime = factory.NewGauge(prometheus.GaugeOpts{Name: "proposer_pool_content_fetch_time"}) // Prover ProverLatestVerifiedIDGauge = factory.NewGauge(prometheus.GaugeOpts{Name: "prover_latestVerified_id"}) diff --git a/packages/taiko-client/proposer/proposer.go b/packages/taiko-client/proposer/proposer.go index 585bf705e22..171bcdb7403 100644 --- a/packages/taiko-client/proposer/proposer.go +++ b/packages/taiko-client/proposer/proposer.go @@ -184,7 +184,10 @@ func (p *Proposer) Close(_ context.Context) { // fetchPoolContent fetches the transaction pool content from L2 execution engine. func (p *Proposer) fetchPoolContent(filterPoolContent bool) ([]types.Transactions, error) { - minTip := p.MinTip + var ( + minTip = p.MinTip + startAt = time.Now() + ) // If `--epoch.allowZeroInterval` flag is set, allow proposing zero tip transactions once when // the total epochs number is divisible by the flag value. if p.AllowZeroInterval > 0 && p.totalEpochs%p.AllowZeroInterval == 0 { @@ -206,6 +209,8 @@ func (p *Proposer) fetchPoolContent(filterPoolContent bool) ([]types.Transaction return nil, fmt.Errorf("failed to fetch transaction pool content: %w", err) } + metrics.ProposerPoolContentFetchTime.Set(time.Since(startAt).Seconds()) + txLists := []types.Transactions{} for i, txs := range preBuiltTxList { // Filter the pool content if the filterPoolContent flag is set.