analytics(app): update telemetry to Ethermint modules (#1106)

* analytics(evm): replace telemetry gauges with counters and add gasUsed counter

* analytics(feemarket): add telemetry gauges for base fee and block gas

* analytics(feemarket): add telemetry gauges for gas_used per gas_limit

* analytics(feemarket): remove refund telemetry

* analytics(app): update CHANGELOG

* remove unwanted change

* address PR comments

* update comment
This commit is contained in:
Daniel Burckhardt 2022-06-02 15:04:33 +02:00 committed by GitHub
parent 046cd00174
commit cad7ff66b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 12 deletions

View File

@ -43,6 +43,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (feemarket) [tharsis#1104](https://github.com/tharsis/ethermint/pull/1104) Enforce a minimum gas price for Cosmos and EVM transactions through the `MinGasPrice` parameter.
- (rpc) [tharsis#1081](https://github.com/tharsis/ethermint/pull/1081) Deduplicate some json-rpc logic codes, cleanup several dead functions.
- (ante) [tharsis#1062](https://github.com/tharsis/ethermint/pull/1062) Emit event of eth tx hash in ante handler to support query failed transactions.
- (analytics) [tharsis#1106](https://github.com/tharsis/ethermint/pull/1106) Update telemetry to Ethermint modules.
### Improvements

View File

@ -30,11 +30,12 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t
tx := msg.AsTransaction()
txIndex := k.GetTxIndexTransient(ctx)
labels := []metrics.Label{telemetry.NewLabel("tx_type", fmt.Sprintf("%d", tx.Type()))}
labels := []metrics.Label{
telemetry.NewLabel("tx_type", fmt.Sprintf("%d", tx.Type())),
telemetry.NewLabel("from", sender),
}
if tx.To() == nil {
labels = []metrics.Label{
telemetry.NewLabel("execution", "create"),
}
labels = []metrics.Label{telemetry.NewLabel("execution", "create")}
} else {
labels = []metrics.Label{
telemetry.NewLabel("execution", "call"),
@ -48,18 +49,31 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t
}
defer func() {
if tx.Value().IsInt64() {
telemetry.SetGauge(
float32(tx.Value().Int64()),
"tx", "msg", "ethereum_tx",
)
}
telemetry.IncrCounterWithLabels(
[]string{types.ModuleName, "ethereum_tx"},
[]string{"tx", "msg", "ethereum_tx", "total"},
1,
labels,
)
if response.GasUsed != 0 {
telemetry.IncrCounterWithLabels(
[]string{"tx", "msg", "ethereum_tx", "gas_used", "total"},
float32(response.GasUsed),
labels,
)
// Observe which users define a gas limit >> gas used. Note, that
// gas_limit and gas_used are always > 0
gasLimit := sdk.NewDec(int64(tx.Gas()))
gasRatio, err := gasLimit.QuoInt64(int64(response.GasUsed)).Float64()
if err == nil {
telemetry.SetGaugeWithLabels(
[]string{"tx", "msg", "ethereum_tx", "gas_limit", "per", "gas_used"},
float32(gasRatio),
labels,
)
}
}
}()
attrs := []sdk.Attribute{

View File

@ -6,6 +6,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tharsis/ethermint/x/feemarket/types"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -20,6 +21,10 @@ func (k *Keeper) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
k.SetBaseFee(ctx, baseFee)
defer func() {
telemetry.SetGauge(float32(baseFee.Int64()), "feemarket", "base_fee")
}()
// Store current base fee in event
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
@ -42,6 +47,10 @@ func (k *Keeper) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) {
k.SetBlockGasUsed(ctx, gasUsed)
defer func() {
telemetry.SetGauge(float32(gasUsed), "feemarket", "block_gas")
}()
ctx.EventManager().EmitEvent(sdk.NewEvent(
"block_gas",
sdk.NewAttribute("height", fmt.Sprintf("%d", ctx.BlockHeight())),