Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

analytics(app): add telemetry to Evmos modules #637

Merged
merged 25 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
99b33bb
analytics(app): add telemetry for deliverTx
danburck May 30, 2022
17dc27c
analytics(app): add telemetry gauge for covnertCoin and covertERC20
danburck May 30, 2022
b83815a
analytics(app): add telemetry gauge for inflation allocation
danburck May 30, 2022
c03a4cf
analytics(app): add telemetry gauge for incentives reward distribution
danburck May 30, 2022
06e433f
analytics(app): add telemetry gauge for recovery
danburck May 30, 2022
b66e42d
analytics(app): add telemetry spec page
danburck May 30, 2022
32253a1
Merge branch 'main' into ENG-382-add-telemetry-cosmos-tx
danburck May 30, 2022
d0939cc
analytics(app): add CHANGELOG
danburck May 30, 2022
b57f939
Merge branch 'ENG-382-add-telemetry-cosmos-tx' of github.com:tharsis/…
danburck May 30, 2022
ec8cf74
analytics(app): replace erc20 gauges with counters
danburck Jun 1, 2022
a58f910
analytics(app): replace remaining gauges with counters and update tel…
danburck Jun 1, 2022
c98391e
analytics(app): update spec
danburck Jun 1, 2022
32803ee
analytics(app): add amount telemetry for relevant modules
danburck Jun 1, 2022
f9eea76
analytics(app): update specs
danburck Jun 1, 2022
c376591
analytics(app): update specs
danburck Jun 1, 2022
9fa000c
analytics(app): update specs
danburck Jun 1, 2022
eb51946
analytics(app): replace total incentives telemetry with one that coun…
danburck Jun 1, 2022
10610c5
analytics(app): move incentives rewards telemetry to include particip…
danburck Jun 1, 2022
49c0c39
analytics(app): add telemetry for gas used on eth txs with incentiviz…
danburck Jun 1, 2022
e161b28
analytics(app): add missing telemetry
danburck Jun 1, 2022
1e2d5d7
analytics(app): move changelog to api breaking
danburck Jun 1, 2022
689bd8b
analytics(app): move total incentives rewards telemetry one level up
danburck Jun 1, 2022
f9fee3a
fix specs
danburck Jun 1, 2022
4c6601a
Merge branch 'main' into ENG-382-add-telemetry-cosmos-tx
danburck Jun 1, 2022
68b69a4
fix broken test
danburck Jun 1, 2022
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (claims) [\#605](https://github.com/tharsis/evmos/pull/605) Remove `claims-` prefix in CLI query commands.
- (erc20) [\#592](https://github.com/tharsis/evmos/pull/592) Finish module completeness audit.

### Improvements

- (analytics) [\#637](https://github.com/tharsis/evmos/pull/637) Add telemetry to Evmos modules
danburck marked this conversation as resolved.
Show resolved Hide resolved

## [v4.0.1] - 2022-05-10

### Bug Fixes
Expand Down
1 change: 0 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,6 @@ func (app *Evmos) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDeliver
app.tpsCounter.incrementSuccess()
}
}()

return app.BaseApp.DeliverTx(req)
}

Expand Down
13 changes: 9 additions & 4 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,20 @@ module.exports = {
{
title: 'For Protocol Devs',
children: [
{
title: 'Modules',
directory: true,
path: '/modules'
},
{
title: 'Module Accounts',
directory: false,
path: '/protocol/moduleaccounts'
},
{
title: 'Module Specifications',
directory: true,
path: '/modules'
title: 'Telemetry',
directory: false,
path: '/protocol/telemetry'
},
{
title: 'Evmos Go API',
Expand Down Expand Up @@ -288,7 +293,7 @@ module.exports = {
forum: {
title: 'Commonwealth Forum',
text: 'Join the Evmos Commonwealth forum',
url: 'https://commonwealth.im/evmos',
url: 'https://commonwealth.im/evmos',
bg: 'linear-gradient(221.79deg, #3D6B99 -1.08%, #336699 95.88%)',
},
github: {
Expand Down
29 changes: 29 additions & 0 deletions docs/protocol/telemetry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--
order: 3
-->

# Telemetry

Gather relevant insights about the Evmos application and modules with custom metrics and telemetry. {synopsis}

To understand how to use the metrics below, please refer to the [Cosmos SDK telemetry documentation](https://docs.cosmos.network/master/core/telemetry.html).

## Supported Metrics

| Metric | Description | Unit | Type |
| :---------------------------------------------- | :------------------------------------------------------------------------------- | :---------- | :------ |
| `ethereum_tx` | Total number of txs processed via the EVM | tx | counter |
| `tx_msg_convert_coin_amount_total` | Total amount of converted coins using a `ConvertCoin` msg | token | counter |
| `tx_msg_convert_coin_total` | Total number of txs with a `ConvertCoin` msg | tx | counter |
| `tx_msg_convert_erc20_amount_total` | Total amount of converted erc20 using a `ConvertERC20` msg | token | counter |
| `tx_msg_convert_erc20_total` | Total number of txs with a `ConvertERC20` msg | tx | counter |
| `tx_msg_ethereum_tx` | Total amount of gas used by an etheruem tx | token | gauge |
| `tx_msg_ethereum_tx_incentives_total` | Total number of txs with an incentivized contract processed via the EVM | tx | counter |
| `incentives_distribute_participants_total` | Total number of participants who received rewards | participant | counter |
| `incentives_distribute_rewards_total` | Total amount of rewards that are distributed to all incentives' participants | token | counter |
| `inflation_hook_allocate_total` | Total amount of tokens allocated through inflation | token | counter |
| `inflation_hook_allocate_staking_total` | Total amount of tokens allocated through inflation to staking | token | counter |
| `inflation_hook_allocate_incentives_total` | Total amount of tokens allocated through inflation to incentives | token | counter |
| `inflation_hook_allocate_community_pool_total` | Total amount of tokens allocated through inflation to community pool | token | counter |
danburck marked this conversation as resolved.
Show resolved Hide resolved
| `recovery_ibc_on_recv_amount_total` | Total amount of tokens recovered using the ibc `onRecvPacket` callback | token | counter |
| `recovery_ibc_on_recv_total` | Total number of recoveries using the ibc `onRecvPacket` callback | recovery | counter |
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ require (
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect
github.com/edsrzf/mmap-go v1.0.0 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.0 // indirect
Expand Down Expand Up @@ -94,6 +96,7 @@ require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/kevinburke/go-bindata v3.23.0+incompatible // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/lib/pq v1.10.4 // indirect
Expand Down Expand Up @@ -140,11 +143,14 @@ require (
github.com/zondax/hid v0.9.0 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.10 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6 // indirect
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGE
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c h1:CndMRAH4JIwxbW8KYq6Q+cGWcGHz0FjGR3QqcInWcW0=
github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
Expand All @@ -376,6 +378,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 h1:IZqZOB2fydHte3kUgxrzK5E1fW7RQGeDwE8F/ZZnUYc=
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILDlzrGEckF6HKjXe48EgsY/l7K7vhY4MW8=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
Expand Down Expand Up @@ -710,6 +714,8 @@ github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/kevinburke/go-bindata v3.23.0+incompatible h1:rqNOXZlqrYhMVVAsQx8wuc+LaA73YcfbQ407wAykyS8=
github.com/kevinburke/go-bindata v3.23.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM=
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM=
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
Expand Down Expand Up @@ -1318,6 +1324,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -1629,6 +1636,7 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20=
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
70 changes: 70 additions & 0 deletions x/erc20/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"math/big"

"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"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -146,6 +148,25 @@ func (k Keeper) convertCoinNativeCoin(
)
}

defer func() {
telemetry.IncrCounterWithLabels(
[]string{"tx", "msg", "convert", "coin", "total"},
1,
[]metrics.Label{
telemetry.NewLabel("coin", pair.Denom),
telemetry.NewLabel("erc20", pair.Erc20Address),
},
)

if msg.Coin.Amount.IsInt64() {
telemetry.IncrCounterWithLabels(
[]string{"tx", "msg", "convert", "coin", "amount", "total"},
float32(msg.Coin.Amount.Int64()),
[]metrics.Label{telemetry.NewLabel("denom", msg.Coin.Denom)},
)
}
}()

ctx.EventManager().EmitEvents(
sdk.Events{
sdk.NewEvent(
Expand Down Expand Up @@ -224,6 +245,25 @@ func (k Keeper) convertERC20NativeCoin(
)
}

defer func() {
telemetry.IncrCounterWithLabels(
[]string{"tx", "msg", "convert", "erc20", "total"},
1,
[]metrics.Label{
telemetry.NewLabel("coin", pair.Denom),
telemetry.NewLabel("erc20", pair.Erc20Address),
},
)

if msg.Amount.IsInt64() {
telemetry.IncrCounterWithLabels(
[]string{"tx", "msg", "convert", "erc20", "amount", "total"},
float32(msg.Amount.Int64()),
[]metrics.Label{telemetry.NewLabel("denom", msg.ContractAddress)},
)
}
}()

ctx.EventManager().EmitEvents(
sdk.Events{
sdk.NewEvent(
Expand Down Expand Up @@ -330,6 +370,17 @@ func (k Keeper) convertERC20NativeToken(
return nil, err
}

defer func() {
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
telemetry.IncrCounterWithLabels(
[]string{"tx", "msg", "convert", "erc20", "total"},
1,
[]metrics.Label{
telemetry.NewLabel("coin", pair.Denom),
telemetry.NewLabel("erc20", pair.Erc20Address),
},
)
}()

ctx.EventManager().EmitEvents(
sdk.Events{
sdk.NewEvent(
Expand Down Expand Up @@ -418,6 +469,25 @@ func (k Keeper) convertCoinNativeERC20(
return nil, err
}

defer func() {
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
telemetry.IncrCounterWithLabels(
[]string{"tx", "msg", "convert", "coin", "total"},
1,
[]metrics.Label{
telemetry.NewLabel("coin", pair.Denom),
telemetry.NewLabel("erc20", pair.Erc20Address),
},
)

if msg.Coin.Amount.IsInt64() {
telemetry.IncrCounterWithLabels(
[]string{"tx", "msg", "convert", "coin", "amount", "total"},
float32(msg.Coin.Amount.Int64()),
[]metrics.Label{telemetry.NewLabel("denom", msg.Coin.Denom)},
)
}
}()

ctx.EventManager().EmitEvents(
sdk.Events{
sdk.NewEvent(
Expand Down
Loading