From 988468a67ba9b484a6acce24b1119839c1bdf195 Mon Sep 17 00:00:00 2001 From: Vinayak Date: Thu, 5 May 2022 22:52:19 +0530 Subject: [PATCH] Skip metric increment during existence check (#12763) * Skip metric increment during existence check Signed-off-by: Vinayak Kadam * Adding changelog.txt Signed-off-by: Vinayak Kadam * Updated changelog text Signed-off-by: Vinayak Kadam --- changelog/12763.txt | 3 +++ vault/router.go | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 changelog/12763.txt diff --git a/changelog/12763.txt b/changelog/12763.txt new file mode 100644 index 000000000..0deac4cf5 --- /dev/null +++ b/changelog/12763.txt @@ -0,0 +1,3 @@ +```release-note: bug +core: Fix double counting for "route" metrics +``` \ No newline at end of file diff --git a/vault/router.go b/vault/router.go index 1c11234eb..c0276f51d 100644 --- a/vault/router.go +++ b/vault/router.go @@ -535,10 +535,12 @@ func (r *Router) routeCommon(ctx context.Context, req *logical.Request, existenc return logical.ErrorResponse(fmt.Sprintf("no handler for route %q. route entry not found.", req.Path)), false, false, logical.ErrUnsupportedPath } req.Path = adjustedPath - defer metrics.MeasureSince([]string{ - "route", string(req.Operation), - strings.Replace(mount, "/", "-", -1), - }, time.Now()) + if !existenceCheck { + defer metrics.MeasureSince([]string{ + "route", string(req.Operation), + strings.Replace(mount, "/", "-", -1), + }, time.Now()) + } re := raw.(*routeEntry) // Grab a read lock on the route entry, this protects against the backend