From d5d5a6d2c0078ffda039cb857db46e3e3d36e55b Mon Sep 17 00:00:00 2001 From: Eric Mokaya Date: Tue, 8 Oct 2024 18:49:47 +0300 Subject: [PATCH 1/3] feat(baseapp): add per message telemetry --- baseapp/baseapp.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 2ef933c205c3..fe97c1e93859 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -1030,9 +1030,10 @@ func (app *BaseApp) runTx(mode execMode, txBytes []byte, tx sdk.Tx) (gInfo sdk.G func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, reflectMsgs []protoreflect.Message, mode execMode) (*sdk.Result, error) { events := sdk.EmptyEvents() msgResponses := make([]*codectypes.Any, 0, len(msgs)) - // NOTE: GasWanted is determined by the AnteHandler and GasUsed by the GasMeter. for i, msg := range msgs { + start := telemetry.Now() + if mode != execModeFinalize && mode != execModeSimulate { break } @@ -1076,6 +1077,8 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, reflectMsgs []proto } msgResponses = append(msgResponses, msgResponse) } + + telemetry.MeasureSince(start, "tx", "msg", "processing_time", sdk.MsgTypeURL(msg)) } data, err := makeABCIData(msgResponses) From 1b6e8c06afdb3e7835b128cc6644840fdd793597 Mon Sep 17 00:00:00 2001 From: Eric Mokaya Date: Thu, 31 Oct 2024 16:41:19 +0300 Subject: [PATCH 2/3] fix(baseapp): move var definition --- baseapp/baseapp.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 4b2a8027d671..98adf6e1a94e 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -1032,12 +1032,12 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, reflectMsgs []proto msgResponses := make([]*codectypes.Any, 0, len(msgs)) // NOTE: GasWanted is determined by the AnteHandler and GasUsed by the GasMeter. for i, msg := range msgs { - start := telemetry.Now() - if mode != execModeFinalize && mode != execModeSimulate { break } + start := telemetry.Now() + handler := app.msgServiceRouter.Handler(msg) if handler == nil { return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "no message handler found for %T", msg) From 4444348ba01a6e36557da86a4dc4541ce784b59a Mon Sep 17 00:00:00 2001 From: Eric Mokaya Date: Mon, 4 Nov 2024 14:19:34 +0300 Subject: [PATCH 3/3] chore(baseapp): changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6d9cc8c6a55..7d88d88ad2d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,6 +89,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (x/validate) [#21822](https://github.com/cosmos/cosmos-sdk/pull/21822) New module solely responsible for providing ante/post handlers and tx validators for v2. It can be extended by the app developer to provide extra tx validators. * In comparison to x/auth/tx/config, there is no app config to skip ante/post handlers, as overwriting them in baseapp or not injecting the x/validate module has the same effect. * (baseapp) [#21979](https://github.com/cosmos/cosmos-sdk/pull/21979) Create CheckTxHandler to allow extending the logic of CheckTx. +* (baseapp) [[#13981](https://github.com/cosmos/cosmos-sdk/issues/13981)] Add per-message telemetry. ### Improvements