@@ -88,6 +88,7 @@ type Command struct {
8888 disableMetrics bool
8989 telemetryProject string
9090 telemetryPrefix string
91+ prometheus bool
9192 prometheusNamespace string
9293 healthCheck bool
9394 httpPort string
@@ -184,8 +185,10 @@ the maximum time has passed. Defaults to 0s.`)
184185 "Disable Cloud Monitoring integration (used with telemetry-project)" )
185186 cmd .PersistentFlags ().StringVar (& c .telemetryPrefix , "telemetry-prefix" , "" ,
186187 "Prefix to use for Cloud Monitoring metrics." )
188+ cmd .PersistentFlags ().BoolVar (& c .prometheus , "prometheus" , false ,
189+ "Enable Prometheus HTTP endpoint /metrics" )
187190 cmd .PersistentFlags ().StringVar (& c .prometheusNamespace , "prometheus-namespace" , "" ,
188- "Enable Prometheus for metric collection using the provided namespace" )
191+ "Use the provided Prometheus namespace for metrics " )
189192 cmd .PersistentFlags ().StringVar (& c .httpPort , "http-port" , "9090" ,
190193 "Port for the Prometheus server to use" )
191194 cmd .PersistentFlags ().BoolVar (& c .healthCheck , "health-check" , false ,
@@ -247,8 +250,8 @@ func parseConfig(cmd *Command, conf *proxy.Config, args []string) error {
247250 cmd .logger .Infof ("Using API Endpoint %v" , conf .APIEndpointURL )
248251 }
249252
250- if userHasSet ("http-port" ) && ! userHasSet ("prometheus-namespace " ) && ! userHasSet ("health-check" ) {
251- cmd .logger .Infof ("Ignoring --http-port because --prometheus-namespace or --health-check was not set" )
253+ if userHasSet ("http-port" ) && ! userHasSet ("prometheus" ) && ! userHasSet ("health-check" ) {
254+ cmd .logger .Infof ("Ignoring --http-port because --prometheus or --health-check was not set" )
252255 }
253256
254257 if ! userHasSet ("telemetry-project" ) && userHasSet ("telemetry-prefix" ) {
@@ -367,7 +370,7 @@ func runSignalWrapper(cmd *Command) error {
367370 needsHTTPServer bool
368371 mux = http .NewServeMux ()
369372 )
370- if cmd .prometheusNamespace != "" {
373+ if cmd .prometheus {
371374 needsHTTPServer = true
372375 e , err := prometheus .NewExporter (prometheus.Options {
373376 Namespace : cmd .prometheusNamespace ,
0 commit comments