Skip to content

Commit

Permalink
Merge pull request #291 from klihub/fixes/disable-instrumentation
Browse files Browse the repository at this point in the history
instrumentation: disable Prometheus exporter, endpoint by default.
  • Loading branch information
klihub authored May 20, 2020
2 parents 215f1f4 + 048fc0a commit e8861cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/instrumentation/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 14 additions & 4 deletions pkg/instrumentation/instrumentation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"flag"
"io/ioutil"
"net/http"
"strings"
"testing"
)

Expand All @@ -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()
Expand Down

0 comments on commit e8861cf

Please sign in to comment.