Skip to content

Commit

Permalink
remove unused chainIDmetrics() (#3992)
Browse files Browse the repository at this point in the history
  • Loading branch information
millken authored Nov 23, 2023
1 parent b2ccaf7 commit 4430e09
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions chainservice/chainservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand All @@ -65,8 +49,6 @@ var (
)

func init() {
prometheus.MustRegister(_apiCallWithChainIDMtc)
prometheus.MustRegister(_apiCallWithOutChainIDMtc)
prometheus.MustRegister(_blockchainFullnessMtc)
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4430e09

Please sign in to comment.