fix(peering): generate token metrics only for leader

This commit is contained in:
DanStough 2022-09-09 17:10:48 -04:00 committed by Dan Stough
parent b37a2ba889
commit f9b4fa17f1
1 changed files with 2 additions and 2 deletions

View File

@ -194,8 +194,6 @@ func (s *Server) GenerateToken(
return nil, fmt.Errorf("meta tags failed validation: %w", err) return nil, fmt.Errorf("meta tags failed validation: %w", err)
} }
defer metrics.MeasureSince([]string{"peering", "generate_token"}, time.Now())
resp := &pbpeering.GenerateTokenResponse{} resp := &pbpeering.GenerateTokenResponse{}
handled, err := s.ForwardRPC(&writeRequest, func(conn *grpc.ClientConn) error { handled, err := s.ForwardRPC(&writeRequest, func(conn *grpc.ClientConn) error {
ctx := external.ForwardMetadataContext(ctx) ctx := external.ForwardMetadataContext(ctx)
@ -207,6 +205,8 @@ func (s *Server) GenerateToken(
return resp, err return resp, err
} }
defer metrics.MeasureSince([]string{"peering", "generate_token"}, time.Now())
var authzCtx acl.AuthorizerContext var authzCtx acl.AuthorizerContext
entMeta := structs.DefaultEnterpriseMetaInPartition(req.Partition) entMeta := structs.DefaultEnterpriseMetaInPartition(req.Partition)
authz, err := s.Backend.ResolveTokenAndDefaultMeta(external.TokenFromContext(ctx), entMeta, &authzCtx) authz, err := s.Backend.ResolveTokenAndDefaultMeta(external.TokenFromContext(ctx), entMeta, &authzCtx)