feat: support disabling grpc histogram (#4075)

This commit is contained in:
Alexander Matyushentsev 2020-08-11 13:28:57 -07:00 committed by GitHub
parent c99ddc46bb
commit cea3c19d62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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(`<base href="(.*)">`)
// 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