feat(metrics): add timing metrics to abci methods (#1669)

* feat(metrics): add timing metrics to abci methods

* update changelog
This commit is contained in:
Robert Pirtle 2023-08-25 15:14:35 -07:00 committed by GitHub
parent 9a0aed7626
commit 8b6bbd36f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 50 additions and 0 deletions

View File

@ -38,6 +38,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Features ### Features
- (metrics) [#1668] Adds non-state breaking x/metrics module for custom telemetry. - (metrics) [#1668] Adds non-state breaking x/metrics module for custom telemetry.
- (metrics) [#1669] Add performance timing metrics to all Begin/EndBlockers
### Bug Fixes ### Bug Fixes
- (evmutil) [#1655] Initialize x/evmutil module account in InitGenesis - (evmutil) [#1655] Initialize x/evmutil module account in InitGenesis
@ -280,6 +281,7 @@ the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.38.4/CHANGELOG.md).
large-scale simulations remotely using aws-batch large-scale simulations remotely using aws-batch
[#1668]: https://github.com/Kava-Labs/kava/pull/1668 [#1668]: https://github.com/Kava-Labs/kava/pull/1668
[#1669]: https://github.com/Kava-Labs/kava/pull/1669
[#1655]: https://github.com/Kava-Labs/kava/pull/1655 [#1655]: https://github.com/Kava-Labs/kava/pull/1655
[#1624]: https://github.com/Kava-Labs/kava/pull/1624 [#1624]: https://github.com/Kava-Labs/kava/pull/1624
[#1631]: https://github.com/Kava-Labs/kava/pull/1631 [#1631]: https://github.com/Kava-Labs/kava/pull/1631

View File

@ -2,7 +2,9 @@ package auction
import ( import (
"errors" "errors"
"time"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/auction/keeper" "github.com/kava-labs/kava/x/auction/keeper"
@ -12,6 +14,8 @@ import (
// BeginBlocker closes all expired auctions at the end of each block. It panics if // BeginBlocker closes all expired auctions at the end of each block. It panics if
// there's an error other than ErrAuctionNotFound. // there's an error other than ErrAuctionNotFound.
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
err := k.CloseExpiredAuctions(ctx) err := k.CloseExpiredAuctions(ctx)
if err != nil && !errors.Is(err, types.ErrAuctionNotFound) { if err != nil && !errors.Is(err, types.ErrAuctionNotFound) {
panic(err) panic(err)

View File

@ -1,13 +1,19 @@
package bep3 package bep3
import ( import (
"time"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/bep3/keeper" "github.com/kava-labs/kava/x/bep3/keeper"
"github.com/kava-labs/kava/x/bep3/types"
) )
// BeginBlocker on every block expires outdated atomic swaps and removes closed // BeginBlocker on every block expires outdated atomic swaps and removes closed
// swap from long term storage (default storage time of 1 week) // swap from long term storage (default storage time of 1 week)
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
k.UpdateTimeBasedSupplyLimits(ctx) k.UpdateTimeBasedSupplyLimits(ctx)
k.UpdateExpiredAtomicSwaps(ctx) k.UpdateExpiredAtomicSwaps(ctx)
k.DeleteClosedAtomicSwapsFromLongtermStorage(ctx) k.DeleteClosedAtomicSwapsFromLongtermStorage(ctx)

View File

@ -2,17 +2,22 @@ package cdp
import ( import (
"errors" "errors"
"time"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/x/cdp/keeper" "github.com/kava-labs/kava/x/cdp/keeper"
"github.com/kava-labs/kava/x/cdp/types"
pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types" pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types"
) )
// BeginBlocker compounds the debt in outstanding cdps and liquidates cdps that are below the required collateralization ratio // BeginBlocker compounds the debt in outstanding cdps and liquidates cdps that are below the required collateralization ratio
func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper) { func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
params := k.GetParams(ctx) params := k.GetParams(ctx)
for _, cp := range params.CollateralParams { for _, cp := range params.CollateralParams {

View File

@ -1,14 +1,20 @@
package committee package committee
import ( import (
"time"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
"github.com/kava-labs/kava/x/committee/keeper" "github.com/kava-labs/kava/x/committee/keeper"
"github.com/kava-labs/kava/x/committee/types"
) )
// BeginBlocker runs at the start of every block. // BeginBlocker runs at the start of every block.
func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper) { func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
k.ProcessProposals(ctx) k.ProcessProposals(ctx)
} }

View File

@ -1,11 +1,17 @@
package hard package hard
import ( import (
"time"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/hard/keeper" "github.com/kava-labs/kava/x/hard/keeper"
"github.com/kava-labs/kava/x/hard/types"
) )
// BeginBlocker updates interest rates // BeginBlocker updates interest rates
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
k.ApplyInterestRateUpdates(ctx) k.ApplyInterestRateUpdates(ctx)
} }

View File

@ -2,14 +2,19 @@ package incentive
import ( import (
"fmt" "fmt"
"time"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/incentive/keeper" "github.com/kava-labs/kava/x/incentive/keeper"
"github.com/kava-labs/kava/x/incentive/types"
) )
// BeginBlocker runs at the start of every block // BeginBlocker runs at the start of every block
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
params := k.GetParams(ctx) params := k.GetParams(ctx)
for _, rp := range params.USDXMintingRewardPeriods { for _, rp := range params.USDXMintingRewardPeriods {

View File

@ -1,12 +1,18 @@
package issuance package issuance
import ( import (
"time"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/issuance/keeper" "github.com/kava-labs/kava/x/issuance/keeper"
"github.com/kava-labs/kava/x/issuance/types"
) )
// BeginBlocker iterates over each asset and seizes coins from blocked addresses by returning them to the asset owner // BeginBlocker iterates over each asset and seizes coins from blocked addresses by returning them to the asset owner
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
err := k.SeizeCoinsForBlockableAssets(ctx) err := k.SeizeCoinsForBlockableAssets(ctx)
if err != nil { if err != nil {
panic(err) panic(err)

View File

@ -1,12 +1,18 @@
package kavadist package kavadist
import ( import (
"time"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/kavadist/keeper" "github.com/kava-labs/kava/x/kavadist/keeper"
"github.com/kava-labs/kava/x/kavadist/types"
) )
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
err := k.MintPeriodInflation(ctx) err := k.MintPeriodInflation(ctx)
if err != nil { if err != nil {
panic(err) panic(err)

View File

@ -2,7 +2,9 @@ package pricefeed
import ( import (
"errors" "errors"
"time"
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/kava-labs/kava/x/pricefeed/keeper" "github.com/kava-labs/kava/x/pricefeed/keeper"
"github.com/kava-labs/kava/x/pricefeed/types" "github.com/kava-labs/kava/x/pricefeed/types"
@ -10,6 +12,8 @@ import (
// EndBlocker updates the current pricefeed // EndBlocker updates the current pricefeed
func EndBlocker(ctx sdk.Context, k keeper.Keeper) { func EndBlocker(ctx sdk.Context, k keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
// Update the current price of each asset. // Update the current price of each asset.
for _, market := range k.GetMarkets(ctx) { for _, market := range k.GetMarkets(ctx) {
if !market.Active { if !market.Active {