From 4430e0914d6bf9b145a2db04a604b797a4790888 Mon Sep 17 00:00:00 2001 From: millken Date: Thu, 23 Nov 2023 08:54:41 +0800 Subject: [PATCH] remove unused chainIDmetrics() (#3992) --- chainservice/chainservice.go | 43 ------------------------------------ 1 file changed, 43 deletions(-) diff --git a/chainservice/chainservice.go b/chainservice/chainservice.go index dc4cfa54f1..dd6157ed82 100644 --- a/chainservice/chainservice.go +++ b/chainservice/chainservice.go @@ -7,14 +7,12 @@ package chainservice import ( "context" - "strconv" "github.com/libp2p/go-libp2p-core/peer" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "google.golang.org/protobuf/proto" - "github.com/iotexproject/iotex-address/address" "github.com/iotexproject/iotex-election/committee" "github.com/iotexproject/iotex-proto/golang/iotexrpc" "github.com/iotexproject/iotex-proto/golang/iotextypes" @@ -41,20 +39,6 @@ import ( ) var ( - _apiCallWithChainIDMtc = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "iotex_apicall_chainid_metrics", - Help: "API call ChainID Statistics", - }, - []string{"chain_id"}, - ) - _apiCallWithOutChainIDMtc = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "iotex_apicall_nochainid_metrics", - Help: "API call Without ChainID Statistics", - }, - []string{"sender", "recipient"}, - ) _blockchainFullnessMtc = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "iotex_blockchain_fullness", @@ -65,8 +49,6 @@ var ( ) func init() { - prometheus.MustRegister(_apiCallWithChainIDMtc) - prometheus.MustRegister(_apiCallWithOutChainIDMtc) prometheus.MustRegister(_blockchainFullnessMtc) } @@ -119,34 +101,9 @@ func (cs *ChainService) HandleAction(ctx context.Context, actPb *iotextypes.Acti if err != nil { log.L().Debug(err.Error()) } - chainIDmetrics(act) return err } -func chainIDmetrics(act action.SealedEnvelope) { - chainID := strconv.FormatUint(uint64(act.ChainID()), 10) - if act.ChainID() > 0 { - _apiCallWithChainIDMtc.WithLabelValues(chainID).Inc() - } else { - recipient, _ := act.Destination() - //it will be empty for staking action, change string to staking in such case - if recipient == "" { - act, ok := act.Action().(action.EthCompatibleAction) - if ok { - if ethTx, err := act.ToEthTx(0); err == nil && ethTx.To() != nil { - if add, err := address.FromHex(ethTx.To().Hex()); err == nil { - recipient = add.String() - } - } - } - if recipient == "" { - recipient = "staking" - } - } - _apiCallWithOutChainIDMtc.WithLabelValues(act.SenderAddress().String(), recipient).Inc() - } -} - // HandleBlock handles incoming block request. func (cs *ChainService) HandleBlock(ctx context.Context, peer string, pbBlock *iotextypes.Block) error { blk, err := block.NewDeserializer(cs.chain.EvmNetworkID()).FromBlockProto(pbBlock)