diff --git a/flyteadmin/pkg/config/config.go b/flyteadmin/pkg/config/config.go index 30a5c49017..4aafb450e3 100644 --- a/flyteadmin/pkg/config/config.go +++ b/flyteadmin/pkg/config/config.go @@ -47,9 +47,10 @@ type DataProxyUploadConfig struct { } type GrpcConfig struct { - Port int `json:"port" pflag:",On which grpc port to serve admin"` - ServerReflection bool `json:"serverReflection" pflag:",Enable GRPC Server Reflection"` - MaxMessageSizeBytes int `json:"maxMessageSizeBytes" pflag:",The max size in bytes for incoming gRPC messages"` + Port int `json:"port" pflag:",On which grpc port to serve admin"` + ServerReflection bool `json:"serverReflection" pflag:",Enable GRPC Server Reflection"` + MaxMessageSizeBytes int `json:"maxMessageSizeBytes" pflag:",The max size in bytes for incoming gRPC messages"` + EnableGrpcHistograms bool `json:"enableGrpcHistograms" pflag:",Enable grpc histograms"` } // KubeClientConfig contains the configuration used by flyteadmin to configure its internal Kubernetes Client. diff --git a/flyteadmin/pkg/config/serverconfig_flags.go b/flyteadmin/pkg/config/serverconfig_flags.go index c37a826032..5e6195e63f 100755 --- a/flyteadmin/pkg/config/serverconfig_flags.go +++ b/flyteadmin/pkg/config/serverconfig_flags.go @@ -66,6 +66,7 @@ func (cfg ServerConfig) GetPFlagSet(prefix string) *pflag.FlagSet { cmdFlags.Int(fmt.Sprintf("%v%v", prefix, "grpc.port"), defaultServerConfig.GrpcConfig.Port, "On which grpc port to serve admin") cmdFlags.Bool(fmt.Sprintf("%v%v", prefix, "grpc.serverReflection"), defaultServerConfig.GrpcConfig.ServerReflection, "Enable GRPC Server Reflection") cmdFlags.Int(fmt.Sprintf("%v%v", prefix, "grpc.maxMessageSizeBytes"), defaultServerConfig.GrpcConfig.MaxMessageSizeBytes, "The max size in bytes for incoming gRPC messages") + cmdFlags.Bool(fmt.Sprintf("%v%v", prefix, "grpc.enableGrpcHistograms"), defaultServerConfig.GrpcConfig.EnableGrpcHistograms, "Enable grpc histograms") cmdFlags.String(fmt.Sprintf("%v%v", prefix, "thirdPartyConfig.flyteClient.clientId"), defaultServerConfig.DeprecatedThirdPartyConfig.FlyteClientConfig.ClientID, "public identifier for the app which handles authorization for a Flyte deployment") cmdFlags.String(fmt.Sprintf("%v%v", prefix, "thirdPartyConfig.flyteClient.redirectUri"), defaultServerConfig.DeprecatedThirdPartyConfig.FlyteClientConfig.RedirectURI, "This is the callback uri registered with the app which handles authorization for a Flyte deployment") cmdFlags.StringSlice(fmt.Sprintf("%v%v", prefix, "thirdPartyConfig.flyteClient.scopes"), defaultServerConfig.DeprecatedThirdPartyConfig.FlyteClientConfig.Scopes, "Recommended scopes for the client to request.") diff --git a/flyteadmin/pkg/config/serverconfig_flags_test.go b/flyteadmin/pkg/config/serverconfig_flags_test.go index b16e0416dd..5c991d5216 100755 --- a/flyteadmin/pkg/config/serverconfig_flags_test.go +++ b/flyteadmin/pkg/config/serverconfig_flags_test.go @@ -323,6 +323,20 @@ func TestServerConfig_SetFlags(t *testing.T) { } }) }) + t.Run("Test_grpc.enableGrpcHistograms", func(t *testing.T) { + + t.Run("Override", func(t *testing.T) { + testValue := "1" + + cmdFlags.Set("grpc.enableGrpcHistograms", testValue) + if vBool, err := cmdFlags.GetBool("grpc.enableGrpcHistograms"); err == nil { + testDecodeJson_ServerConfig(t, fmt.Sprintf("%v", vBool), &actual.GrpcConfig.EnableGrpcHistograms) + + } else { + assert.FailNow(t, err.Error()) + } + }) + }) t.Run("Test_thirdPartyConfig.flyteClient.clientId", func(t *testing.T) { t.Run("Override", func(t *testing.T) { diff --git a/flyteadmin/pkg/server/service.go b/flyteadmin/pkg/server/service.go index 5d8135a8c4..4cb5a90362 100644 --- a/flyteadmin/pkg/server/service.go +++ b/flyteadmin/pkg/server/service.go @@ -80,6 +80,11 @@ func newGRPCServer(ctx context.Context, pluginRegistry *plugins.Registry, cfg *c pluginRegistry.RegisterDefault(plugins.PluginIDUnaryServiceMiddleware, grpcmiddleware.ChainUnaryServer( RequestIDInterceptor, auth.BlanketAuthorization, auth.ExecutionUserIdentifierInterceptor)) + if cfg.GrpcConfig.EnableGrpcHistograms { + logger.Debugf(ctx, "enabling grpc histogram metrics") + grpcprometheus.EnableHandlingTimeHistogram() + } + // Not yet implemented for streaming var chainedUnaryInterceptors grpc.UnaryServerInterceptor if cfg.Security.UseAuth {