From cea3c19d625f519411f2ccded68c79928edfbc53 Mon Sep 17 00:00:00 2001 From: Alexander Matyushentsev Date: Tue, 11 Aug 2020 13:28:57 -0700 Subject: [PATCH] feat: support disabling grpc histogram (#4075) --- server/server.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/server.go b/server/server.go index 1974cd031f..32c99484a6 100644 --- a/server/server.go +++ b/server/server.go @@ -101,6 +101,7 @@ import ( const maxConcurrentLoginRequestsCountEnv = "ARGOCD_MAX_CONCURRENT_LOGIN_REQUESTS_COUNT" const replicasCountEnv = "ARGOCD_API_SERVER_REPLICAS" +const enableGRPCTimeHistogramEnv = "ARGOCD_ENABLE_GRPC_TIME_HISTOGRAM" // ErrNoSession indicates no auth token was supplied as part of a request var ErrNoSession = status.Errorf(codes.Unauthenticated, "no session information") @@ -124,8 +125,8 @@ var ( baseHRefRegex = regexp.MustCompile(``) // limits number of concurrent login requests to prevent password brute forcing. If set to 0 then no limit is enforced. maxConcurrentLoginRequestsCount = 50 - - replicasCount = 1 + replicasCount = 1 + enableGRPCTimeHistogram = true ) func init() { @@ -134,6 +135,7 @@ func init() { if replicasCount > 0 { maxConcurrentLoginRequestsCount = maxConcurrentLoginRequestsCount / replicasCount } + enableGRPCTimeHistogram = os.Getenv(enableGRPCTimeHistogramEnv) != "false" } // ArgoCDServer is the API server for Argo CD @@ -454,7 +456,9 @@ func (a *ArgoCDServer) useTLS() bool { } func (a *ArgoCDServer) newGRPCServer() *grpc.Server { - grpc_prometheus.EnableHandlingTimeHistogram() + if enableGRPCTimeHistogram { + grpc_prometheus.EnableHandlingTimeHistogram() + } sOpts := []grpc.ServerOption{ // Set the both send and receive the bytes limit to be 100MB