forked from cerc-io/laconicd-deprecated
		
	impr(evm): add tx_type, gas and counter telemetry for ethereum txs (#1101)
* impr(evm): add tx_type, gas and counter telemetry for ethereum txs * impr(evm): Add CHANGELOG
This commit is contained in:
		
							parent
							
								
									d23fb0c37d
								
							
						
					
					
						commit
						928e018aa9
					
				| @ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ | ||||
| 
 | ||||
| * (cli) [tharsis#1086](https://github.com/tharsis/ethermint/pull/1086) Add rollback command. | ||||
| * (specs) [tharsis#1095](https://github.com/tharsis/ethermint/pull/1095) Add more evm specs concepts. | ||||
| * (evm) [tharsis#1101](https://github.com/tharsis/ethermint/pull/1101) Add tx_type, gas and counter telemetry for ethereum txs. | ||||
| 
 | ||||
| ### Bug Fixes | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							| @ -3,6 +3,7 @@ module github.com/tharsis/ethermint | ||||
| go 1.17 | ||||
| 
 | ||||
| require ( | ||||
| 	github.com/armon/go-metrics v0.3.10 | ||||
| 	github.com/btcsuite/btcd v0.22.1 | ||||
| 	github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce | ||||
| 	github.com/cosmos/cosmos-sdk v0.45.4 | ||||
| @ -45,7 +46,6 @@ require ( | ||||
| 	github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect | ||||
| 	github.com/VictoriaMetrics/fastcache v1.6.0 // indirect | ||||
| 	github.com/Workiva/go-datastructures v1.0.53 // indirect | ||||
| 	github.com/armon/go-metrics v0.3.10 // indirect | ||||
| 	github.com/beorn7/perks v1.0.1 // indirect | ||||
| 	github.com/bgentry/speakeasy v0.1.0 // indirect | ||||
| 	github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect | ||||
|  | ||||
| @ -9,6 +9,8 @@ import ( | ||||
| 	tmbytes "github.com/tendermint/tendermint/libs/bytes" | ||||
| 	tmtypes "github.com/tendermint/tendermint/types" | ||||
| 
 | ||||
| 	"github.com/armon/go-metrics" | ||||
| 	"github.com/cosmos/cosmos-sdk/telemetry" | ||||
| 	sdk "github.com/cosmos/cosmos-sdk/types" | ||||
| 	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||||
| 
 | ||||
| @ -28,11 +30,38 @@ 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()))} | ||||
| 	if tx.To() == nil { | ||||
| 		labels = []metrics.Label{ | ||||
| 			telemetry.NewLabel("execution", "create"), | ||||
| 		} | ||||
| 	} else { | ||||
| 		labels = []metrics.Label{ | ||||
| 			telemetry.NewLabel("execution", "call"), | ||||
| 			telemetry.NewLabel("to", tx.To().Hex()), // recipient address (contract or account)
 | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	response, err := k.ApplyTransaction(ctx, tx) | ||||
| 	if err != nil { | ||||
| 		return nil, sdkerrors.Wrap(err, "failed to apply transaction") | ||||
| 	} | ||||
| 
 | ||||
| 	defer func() { | ||||
| 		if tx.Value().IsInt64() { | ||||
| 			telemetry.SetGauge( | ||||
| 				float32(tx.Value().Int64()), | ||||
| 				"tx", "msg", "ethereum_tx", | ||||
| 			) | ||||
| 		} | ||||
| 
 | ||||
| 		telemetry.IncrCounterWithLabels( | ||||
| 			[]string{types.ModuleName, "ethereum_tx"}, | ||||
| 			1, | ||||
| 			labels, | ||||
| 		) | ||||
| 	}() | ||||
| 
 | ||||
| 	attrs := []sdk.Attribute{ | ||||
| 		sdk.NewAttribute(sdk.AttributeKeyAmount, tx.Value().String()), | ||||
| 		// add event for ethereum transaction hash format
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user