diff --git a/pkg/instrumentation/flags.go b/pkg/instrumentation/flags.go index 43a7ac6f6..22273b683 100644 --- a/pkg/instrumentation/flags.go +++ b/pkg/instrumentation/flags.go @@ -47,9 +47,9 @@ const ( // defaultJaegerAgent is the default Jaeger agent endpoint. defaultJaegerAgent = "" // defaultHTTPEndpoint is the default HTTP endpoint serving Prometheus /metrics. - defaultHTTPEndpoint = ":8888" + defaultHTTPEndpoint = "" // defaultPrometheusExport is the default state for Prometheus exporting. - defaultPrometheusExport = "true" + defaultPrometheusExport = "false" ) // options encapsulates our configurable instrumentation parameters. diff --git a/pkg/instrumentation/instrumentation_test.go b/pkg/instrumentation/instrumentation_test.go index 2a2141fa9..9c4685097 100644 --- a/pkg/instrumentation/instrumentation_test.go +++ b/pkg/instrumentation/instrumentation_test.go @@ -18,6 +18,7 @@ import ( "flag" "io/ioutil" "net/http" + "strings" "testing" ) @@ -42,22 +43,31 @@ func TestSamplingIdempotency(t *testing.T) { func TestPrometheusConfiguration(t *testing.T) { flag.Set("logger-debug", "all") + if opt.HTTPEndpoint == "" { + opt.HTTPEndpoint = ":0" + } + s := newService() s.Start() - checkPrometheus(t, opt.HTTPEndpoint, !opt.PrometheusExport) + address := s.http.GetAddress() + if strings.HasSuffix(opt.HTTPEndpoint, ":0") { + opt.HTTPEndpoint = address + } + + checkPrometheus(t, address, !opt.PrometheusExport) opt.PrometheusExport = !opt.PrometheusExport s.reconfigure() - checkPrometheus(t, opt.HTTPEndpoint, !opt.PrometheusExport) + checkPrometheus(t, address, !opt.PrometheusExport) opt.PrometheusExport = !opt.PrometheusExport s.reconfigure() - checkPrometheus(t, opt.HTTPEndpoint, !opt.PrometheusExport) + checkPrometheus(t, address, !opt.PrometheusExport) opt.PrometheusExport = !opt.PrometheusExport s.reconfigure() - checkPrometheus(t, opt.HTTPEndpoint, !opt.PrometheusExport) + checkPrometheus(t, address, !opt.PrometheusExport) s.http.Shutdown(true) s.Stop()