Skip to content

Commit e8861cf

Browse files
authored
Merge pull request #291 from klihub/fixes/disable-instrumentation
instrumentation: disable Prometheus exporter, endpoint by default.
2 parents 215f1f4 + 048fc0a commit e8861cf

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

pkg/instrumentation/flags.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ const (
4747
// defaultJaegerAgent is the default Jaeger agent endpoint.
4848
defaultJaegerAgent = ""
4949
// defaultHTTPEndpoint is the default HTTP endpoint serving Prometheus /metrics.
50-
defaultHTTPEndpoint = ":8888"
50+
defaultHTTPEndpoint = ""
5151
// defaultPrometheusExport is the default state for Prometheus exporting.
52-
defaultPrometheusExport = "true"
52+
defaultPrometheusExport = "false"
5353
)
5454

5555
// options encapsulates our configurable instrumentation parameters.

pkg/instrumentation/instrumentation_test.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"flag"
1919
"io/ioutil"
2020
"net/http"
21+
"strings"
2122
"testing"
2223
)
2324

@@ -42,22 +43,31 @@ func TestSamplingIdempotency(t *testing.T) {
4243
func TestPrometheusConfiguration(t *testing.T) {
4344
flag.Set("logger-debug", "all")
4445

46+
if opt.HTTPEndpoint == "" {
47+
opt.HTTPEndpoint = ":0"
48+
}
49+
4550
s := newService()
4651
s.Start()
4752

48-
checkPrometheus(t, opt.HTTPEndpoint, !opt.PrometheusExport)
53+
address := s.http.GetAddress()
54+
if strings.HasSuffix(opt.HTTPEndpoint, ":0") {
55+
opt.HTTPEndpoint = address
56+
}
57+
58+
checkPrometheus(t, address, !opt.PrometheusExport)
4959

5060
opt.PrometheusExport = !opt.PrometheusExport
5161
s.reconfigure()
52-
checkPrometheus(t, opt.HTTPEndpoint, !opt.PrometheusExport)
62+
checkPrometheus(t, address, !opt.PrometheusExport)
5363

5464
opt.PrometheusExport = !opt.PrometheusExport
5565
s.reconfigure()
56-
checkPrometheus(t, opt.HTTPEndpoint, !opt.PrometheusExport)
66+
checkPrometheus(t, address, !opt.PrometheusExport)
5767

5868
opt.PrometheusExport = !opt.PrometheusExport
5969
s.reconfigure()
60-
checkPrometheus(t, opt.HTTPEndpoint, !opt.PrometheusExport)
70+
checkPrometheus(t, address, !opt.PrometheusExport)
6171

6272
s.http.Shutdown(true)
6373
s.Stop()

0 commit comments

Comments
 (0)