From 485e1b5d4ef0a2ac80a44a1afc78cafa0028d23a Mon Sep 17 00:00:00 2001 From: DanStough Date: Fri, 9 Sep 2022 17:10:48 -0400 Subject: [PATCH] fix(peering): generate token metrics only for leader --- agent/rpc/peering/service.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/rpc/peering/service.go b/agent/rpc/peering/service.go index 8694baf600..17b862ffae 100644 --- a/agent/rpc/peering/service.go +++ b/agent/rpc/peering/service.go @@ -194,8 +194,6 @@ func (s *Server) GenerateToken( return nil, fmt.Errorf("meta tags failed validation: %w", err) } - defer metrics.MeasureSince([]string{"peering", "generate_token"}, time.Now()) - resp := &pbpeering.GenerateTokenResponse{} handled, err := s.ForwardRPC(&writeRequest, func(conn *grpc.ClientConn) error { ctx := external.ForwardMetadataContext(ctx) @@ -207,6 +205,8 @@ func (s *Server) GenerateToken( return resp, err } + defer metrics.MeasureSince([]string{"peering", "generate_token"}, time.Now()) + var authzCtx acl.AuthorizerContext entMeta := structs.DefaultEnterpriseMetaInPartition(req.Partition) authz, err := s.Backend.ResolveTokenAndDefaultMeta(external.TokenFromContext(ctx), entMeta, &authzCtx)