Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

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

Merged
merged 8 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 21 additions & 8 deletions x/evm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t
if tx.To() == nil {
labels = []metrics.Label{
telemetry.NewLabel("execution", "create"),
telemetry.NewLabel("from", sender),
danburck marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
labels = []metrics.Label{
telemetry.NewLabel("execution", "call"),
telemetry.NewLabel("to", tx.To().Hex()), // recipient address (contract or account)
telemetry.NewLabel("from", sender),
}
}

Expand All @@ -48,18 +50,29 @@ 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,
)

gasUsed := sdk.NewDec(int64(response.GasUsed))
gasRatio, err := gasUsed.QuoInt64(int64(tx.Gas())).Float64()
danburck marked this conversation as resolved.
Show resolved Hide resolved
if err == nil {
telemetry.SetGaugeWithLabels(
[]string{"tx", "msg", "ethereum_tx", "gas_used", "per", "gas_limit"},
float32(gasRatio),
labels,
)
}
}
}()

attrs := []sdk.Attribute{
Expand Down
9 changes: 9 additions & 0 deletions x/feemarket/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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(
Expand All @@ -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")
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
}()

ctx.EventManager().EmitEvent(sdk.NewEvent(
"block_gas",
sdk.NewAttribute("height", fmt.Sprintf("%d", ctx.BlockHeight())),
Expand Down