From 2e7bed9e723f92d26f6767740b0a7b2e9caa3dfe Mon Sep 17 00:00:00 2001 From: Tyler <48813565+technicallyty@users.noreply.github.com> Date: Thu, 17 Apr 2025 11:02:17 -0700 Subject: [PATCH] chore: add telemetry measurement to x/auth PreBlocker (#24541) --- CHANGELOG.md | 2 ++ telemetry/wrapper.go | 1 + x/auth/module.go | 3 +++ x/upgrade/abci.go | 2 ++ 4 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dc4e99aa0..f63f32c157 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* (telemetry) [#24541](https://github.com/cosmos/cosmos-sdk/pull/24541) Telemetry now includes a pre_blocker metric key. x/upgrade should migrate to this key in v0.54.0. +* (x/auth) [#24541](https://github.com/cosmos/cosmos-sdk/pull/24541) x/auth's PreBlocker now emits telemetry under the pre_blocker metric key. * (x/bank) [#24431](https://github.com/cosmos/cosmos-sdk/pull/24431) Reduce the number of `ValidateDenom` calls in `bank.SendCoins` and `Coin`. * The `AmountOf()` method on`sdk.Coins` no longer will `panic` if given an invalid denom and will instead return a zero value. * (x/staking) [#24391](https://github.com/cosmos/cosmos-sdk/pull/24391) Replace panics with error results; more verbose error messages diff --git a/telemetry/wrapper.go b/telemetry/wrapper.go index 4362c46a44..8445ed8238 100644 --- a/telemetry/wrapper.go +++ b/telemetry/wrapper.go @@ -8,6 +8,7 @@ import ( // Common metric key constants const ( + MetricKeyPreBlocker = "pre_blocker" MetricKeyBeginBlocker = "begin_blocker" MetricKeyEndBlocker = "end_blocker" MetricLabelNameModule = "module" diff --git a/x/auth/module.go b/x/auth/module.go index d3e8f1c30b..ec8d49a102 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -16,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/telemetry" "github.com/cosmos/cosmos-sdk/testutil/simsx" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -99,6 +100,8 @@ type AppModule struct { // PreBlock cleans up expired unordered transaction nonces from state. // Please ensure to add `x/auth`'s module name to the OrderPreBlocker list in your application. func (am AppModule) PreBlock(ctx context.Context) (appmodule.ResponsePreBlock, error) { + start := telemetry.Now() + defer telemetry.ModuleMeasureSince(types.ModuleName, start, telemetry.MetricKeyPreBlocker) err := am.accountKeeper.RemoveExpiredUnorderedNonces(sdk.UnwrapSDKContext(ctx)) if err != nil { return nil, err diff --git a/x/upgrade/abci.go b/x/upgrade/abci.go index 3018fa16ef..6f2cabcc60 100644 --- a/x/upgrade/abci.go +++ b/x/upgrade/abci.go @@ -22,6 +22,8 @@ import ( // The purpose is to ensure the binary is switched EXACTLY at the desired block, and to allow // a migration to be executed if needed upon this switch (migration defined in the new binary) // skipUpgradeHeightArray is a set of block heights for which the upgrade must be skipped +// +// Note: The MetricKey will change to MetricKeyPreBlocker in v0.54.0. func PreBlocker(ctx context.Context, k *keeper.Keeper) (appmodule.ResponsePreBlock, error) { defer telemetry.ModuleMeasureSince(types.ModuleName, telemetry.Now(), telemetry.MetricKeyBeginBlocker)