Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions otelconf/v0.2.0/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1201,11 +1201,15 @@ func TestPrometheusIPv6(t *testing.T) {
}

rs, err := prometheusReader(t.Context(), &cfg)
require.NoError(t, err)

// Register the reader with a MeterProvider so that scraping
// /metrics below does not log a "reader is not registered" error.
mp := sdkmetric.NewMeterProvider(sdkmetric.WithReader(rs))
t.Cleanup(func() {
//nolint:usetesting // required to avoid getting a canceled context at cleanup.
require.NoError(t, rs.Shutdown(context.Background()))
require.NoError(t, mp.Shutdown(context.Background()))
})
require.NoError(t, err)

hServ := rs.(readerWithServer).server
assert.True(t, strings.HasPrefix(hServ.Addr, "[::1]:"))
Expand Down Expand Up @@ -1293,9 +1297,12 @@ func TestPrometheusReaderConfigurationOptions(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, reader)

// Register the reader with a MeterProvider so that scraping /metrics
// below does not log a "reader is not registered" error.
mp := sdkmetric.NewMeterProvider(sdkmetric.WithReader(reader))
t.Cleanup(func() {
//nolint:usetesting // required to avoid getting a canceled context at cleanup.
require.NoError(t, reader.Shutdown(context.Background()))
require.NoError(t, mp.Shutdown(context.Background()))
})

rws, ok := reader.(readerWithServer)
Expand Down
13 changes: 10 additions & 3 deletions otelconf/v0.3.0/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1434,11 +1434,15 @@ func TestPrometheusIPv6(t *testing.T) {
}

rs, err := prometheusReader(t.Context(), &cfg)
require.NoError(t, err)

// Register the reader with a MeterProvider so that scraping
// /metrics below does not log a "reader is not registered" error.
mp := sdkmetric.NewMeterProvider(sdkmetric.WithReader(rs))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like TestPrometheusIPv6 in otelconf/x/metric_test.go has the same pattern and still logs this warning. Should we update that test as well?

t.Cleanup(func() {
//nolint:usetesting // required to avoid getting a canceled context at cleanup.
require.NoError(t, rs.Shutdown(context.Background()))
require.NoError(t, mp.Shutdown(context.Background()))
})
require.NoError(t, err)

hServ := rs.(readerWithServer).server
assert.True(t, strings.HasPrefix(hServ.Addr, "[::1]:"))
Expand Down Expand Up @@ -1572,9 +1576,12 @@ func TestPrometheusReaderConfigurationOptions(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, reader)

// Register the reader with a MeterProvider so that scraping /metrics
// below does not log a "reader is not registered" error.
mp := sdkmetric.NewMeterProvider(sdkmetric.WithReader(reader))
t.Cleanup(func() {
//nolint:usetesting // required to avoid getting a canceled context at cleanup.
require.NoError(t, reader.Shutdown(context.Background()))
require.NoError(t, mp.Shutdown(context.Background()))
})

rws, ok := reader.(readerWithServer)
Expand Down
8 changes: 6 additions & 2 deletions otelconf/x/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1615,11 +1615,15 @@ func TestPrometheusIPv6(t *testing.T) {
}

rs, err := prometheusReader(t.Context(), &cfg)
require.NoError(t, err)

// Register the reader with a MeterProvider so that scraping
// /metrics below does not log a "reader is not registered" error.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these comments are needed

mp := sdkmetric.NewMeterProvider(sdkmetric.WithReader(rs))
t.Cleanup(func() {
//nolint:usetesting // required to avoid getting a canceled context at cleanup.
require.NoError(t, rs.Shutdown(context.Background()))
require.NoError(t, mp.Shutdown(context.Background()))
})
require.NoError(t, err)

hServ := rs.(readerWithServer).server
assert.True(t, strings.HasPrefix(hServ.Addr, "[::1]:"))
Expand Down
Loading