Skip to content

Commit f376e01

Browse files
committed
Fix tests by using specific meter providers
1 parent 188501e commit f376e01

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

extra/redisotel/metrics_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/stretchr/testify/assert"
99
"github.com/stretchr/testify/require"
1010

11-
"go.opentelemetry.io/otel"
1211
"go.opentelemetry.io/otel/attribute"
1312
"go.opentelemetry.io/otel/metric"
1413
"go.opentelemetry.io/otel/sdk/instrumentation"
@@ -26,8 +25,8 @@ var instrumentationScope = instrumentation.Scope{
2625
func setupMetrics(conf *config) (*sdkmetric.ManualReader, *redis.Client) {
2726
reader := sdkmetric.NewManualReader()
2827
mp := sdkmetric.NewMeterProvider(sdkmetric.WithReader(reader))
29-
otel.SetMeterProvider(mp)
30-
28+
conf.mp = mp
29+
3130
rdb := redis.NewClient(&redis.Options{
3231
Addr: ":6379",
3332
})
@@ -43,7 +42,7 @@ func setupMetrics(conf *config) (*sdkmetric.ManualReader, *redis.Client) {
4342

4443
func TestMetrics(t *testing.T) {
4544
reader, rdb := setupMetrics(newConfig())
46-
rdb.Get(context.Background(), "key")
45+
rdb.Ping(context.Background())
4746

4847
want := metricdata.ScopeMetrics{
4948
Scope: instrumentationScope,
@@ -99,7 +98,7 @@ func TestCustomAttributes(t *testing.T) {
9998
config := newConfig(WithAttributesFunc(customAttrFn))
10099
reader, rdb := setupMetrics(config)
101100

102-
rdb.Get(context.Background(), "key")
101+
rdb.Ping(context.Background())
103102

104103
want := metricdata.ScopeMetrics{
105104
Scope: instrumentationScope,

0 commit comments

Comments
 (0)