@@ -76,6 +76,7 @@ type Command struct {
7676 disableMetrics bool
7777 telemetryProject string
7878 telemetryPrefix string
79+ prometheus bool
7980 prometheusNamespace string
8081 healthCheck bool
8182 httpPort string
@@ -169,8 +170,10 @@ the maximum time has passed. Defaults to 0s.`)
169170 "Disable Cloud Monitoring integration (used with telemetry-project)" )
170171 cmd .PersistentFlags ().StringVar (& c .telemetryPrefix , "telemetry-prefix" , "" ,
171172 "Prefix to use for Cloud Monitoring metrics." )
173+ cmd .PersistentFlags ().BoolVar (& c .prometheus , "prometheus" , false ,
174+ "Enable Prometheus HTTP endpoint /metrics" )
172175 cmd .PersistentFlags ().StringVar (& c .prometheusNamespace , "prometheus-namespace" , "" ,
173- "Enable Prometheus for metric collection using the provided namespace" )
176+ "Use the provided Prometheus namespace for metrics " )
174177 cmd .PersistentFlags ().StringVar (& c .httpPort , "http-port" , "9090" ,
175178 "Port for the Prometheus server to use" )
176179 cmd .PersistentFlags ().BoolVar (& c .healthCheck , "health-check" , false ,
@@ -230,8 +233,8 @@ func parseConfig(cmd *Command, conf *proxy.Config, args []string) error {
230233 return newBadCommandError ("cannot specify --credentials-file and --gcloud-auth flags at the same time" )
231234 }
232235
233- if userHasSet ("http-port" ) && ! userHasSet ("prometheus-namespace " ) && ! userHasSet ("health-check" ) {
234- cmd .logger .Infof ("Ignoring --http-port because --prometheus-namespace or --health-check was not set" )
236+ if userHasSet ("http-port" ) && ! userHasSet ("prometheus" ) && ! userHasSet ("health-check" ) {
237+ cmd .logger .Infof ("Ignoring --http-port because --prometheus or --health-check was not set" )
235238 }
236239
237240 if ! userHasSet ("telemetry-project" ) && userHasSet ("telemetry-prefix" ) {
@@ -402,7 +405,7 @@ func runSignalWrapper(cmd *Command) error {
402405 needsHTTPServer bool
403406 mux = http .NewServeMux ()
404407 )
405- if cmd .prometheusNamespace != "" {
408+ if cmd .prometheus {
406409 needsHTTPServer = true
407410 e , err := prometheus .NewExporter (prometheus.Options {
408411 Namespace : cmd .prometheusNamespace ,
0 commit comments