diff --git a/pkg/instrumentation/instrumentation_test.go b/pkg/instrumentation/instrumentation_test.go index efa609839..e274bcf5c 100644 --- a/pkg/instrumentation/instrumentation_test.go +++ b/pkg/instrumentation/instrumentation_test.go @@ -15,11 +15,13 @@ package instrumentation import ( - "io/ioutil" + "io" "net/http" "strings" "testing" + + "github.com/stretchr/testify/require" ) func TestPrometheusConfiguration(t *testing.T) { @@ -29,7 +31,7 @@ func TestPrometheusConfiguration(t *testing.T) { cfg.HTTPEndpoint = ":0" } - Start() + require.NoError(t, Start(), "start test server") address := srv.GetAddress() if strings.HasSuffix(cfg.HTTPEndpoint, ":0") { @@ -40,17 +42,17 @@ func TestPrometheusConfiguration(t *testing.T) { newCfg := *cfg newCfg.PrometheusExport = !newCfg.PrometheusExport - Reconfigure(&newCfg) + require.NoError(t, Reconfigure(&newCfg), "reconfigure test server") checkPrometheus(t, address, !newCfg.PrometheusExport) newCfg = *cfg newCfg.PrometheusExport = !newCfg.PrometheusExport - Reconfigure(&newCfg) + require.NoError(t, Reconfigure(&newCfg), "reconfigure test server") checkPrometheus(t, address, !newCfg.PrometheusExport) newCfg = *cfg newCfg.PrometheusExport = !newCfg.PrometheusExport - Reconfigure(&newCfg) + require.NoError(t, Reconfigure(&newCfg), "reconfigure test server") checkPrometheus(t, address, !newCfg.PrometheusExport) srv.Shutdown(true) @@ -73,7 +75,7 @@ func checkPrometheus(t *testing.T, server string, shouldFail bool) { return } - _, err = ioutil.ReadAll(rpl.Body) + _, err = io.ReadAll(rpl.Body) rpl.Body.Close() if err != nil { t.Errorf("failed to read Prometheus response: %v", err) diff --git a/pkg/instrumentation/metrics/metrics.go b/pkg/instrumentation/metrics/metrics.go index a036156ca..fbd387df4 100644 --- a/pkg/instrumentation/metrics/metrics.go +++ b/pkg/instrumentation/metrics/metrics.go @@ -34,7 +34,7 @@ type ( var ( disabled bool - namespace string + namespace = "nri" enabled []string polled []string reportPeriod time.Duration @@ -99,7 +99,7 @@ func Start(m *http.ServeMux, options ...Option) error { log.Info("starting metrics exporter...") g, err := metrics.NewGatherer( - metrics.WithNamespace("nri"), + metrics.WithNamespace(namespace), metrics.WithPollInterval(reportPeriod), metrics.WithMetrics(enabled, polled), ) diff --git a/pkg/instrumentation/tracing/exporter.go b/pkg/instrumentation/tracing/exporter.go index 084335bba..437b0a2fb 100644 --- a/pkg/instrumentation/tracing/exporter.go +++ b/pkg/instrumentation/tracing/exporter.go @@ -59,7 +59,9 @@ func (e *spanExporter) Shutdown(ctx context.Context) error { } func (e *spanExporter) setEndpoint(endpoint string) error { - e.shutdown() + if err := e.shutdown(); err != nil { + log.Warnf("failed to shutdown tracing exporter: %v", err) + } if endpoint == "" { return nil