From a82cd2f35d9456e5c8080889736ecfc00c224c6c Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 6 Jul 2022 12:21:03 +0200 Subject: [PATCH] feat: add query telemetry (backport #12405) (#12463) * feat: add query telemetry (#12405) Closes: #12333 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) (cherry picked from commit f70b67fc917baeb5060d63f124a9031ce1210c6a) * Changelog fix Co-authored-by: Robert Zaremba --- CHANGELOG.md | 4 ++++ baseapp/abci.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3606ec701214..b7b4f7842a32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,10 @@ Since **v0.45.15**, the v0.45.x line of the Cosmos SDK has reached end-of-life. Any release after **v0.45.15** is a security release that contains security fixes. It is strongly recommended to upgrade to these releases as well. +### Features + +* (telemetry) [#12405](https://github.com/cosmos/cosmos-sdk/pull/12405) Add _query_ calls metric to telemetry. + ## [v0.46.0-rc2](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0-rc2) - 2022-07-05 ### Features diff --git a/baseapp/abci.go b/baseapp/abci.go index 92065d567cd6..b4356dbf3d01 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -516,6 +516,10 @@ func (app *BaseApp) Query(_ context.Context, req *abci.QueryRequest) (resp *abci return sdkerrors.QueryResultWithDebug(sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "can't route a broadcast tx message"), app.trace) } + telemetry.IncrCounter(1, "query", "count") + telemetry.IncrCounter(1, "query", req.Path) + defer telemetry.MeasureSince(time.Now(), req.Path) + // handle gRPC routes first rather than calling splitPath because '/' characters // are used as part of gRPC paths if grpcHandler := app.grpcQueryRouter.Route(req.Path); grpcHandler != nil {