From d5f24de7e170c57a10a5c53fe83daef507506440 Mon Sep 17 00:00:00 2001 From: beep Date: Mon, 30 Sep 2024 02:19:15 +0800 Subject: [PATCH] fix(baseapp): `startTime` of `telemetry metric` should be calculated before `defer` (#21968) --- baseapp/abci.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index 05b9e61794a7..f0f24ef52844 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -180,7 +180,8 @@ func (app *BaseApp) Query(_ context.Context, req *abci.QueryRequest) (resp *abci telemetry.IncrCounter(1, "query", "count") telemetry.IncrCounter(1, "query", req.Path) - defer telemetry.MeasureSince(telemetry.Now(), req.Path) + start := telemetry.Now() + defer telemetry.MeasureSince(start, req.Path) if req.Path == QueryPathBroadcastTx { return queryResult(errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "can't route a broadcast tx message"), app.trace), nil