Skip to content

Commit

Permalink
reproduce #4741 in a unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
dashpole committed Dec 6, 2023
1 parent d37d851 commit 13161fe
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions sdk/metric/meter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1589,15 +1589,16 @@ func TestObservableExample(t *testing.T) {
)

selector := func(InstrumentKind) metricdata.Temporality { return temp }
reader := NewManualReader(WithTemporalitySelector(selector))
reader1 := NewManualReader(WithTemporalitySelector(selector))
reader2 := NewManualReader(WithTemporalitySelector(selector))

allowAll := attribute.NewDenyKeysFilter()
noFiltered := NewView(Instrument{Name: instName}, Stream{Name: instName, AttributeFilter: allowAll})

filter := attribute.NewDenyKeysFilter("tid")
filtered := NewView(Instrument{Name: instName}, Stream{Name: filteredStream, AttributeFilter: filter})

mp := NewMeterProvider(WithReader(reader), WithView(noFiltered, filtered))
mp := NewMeterProvider(WithReader(reader1), WithReader(reader2), WithView(noFiltered, filtered))
meter := mp.Meter(scopeName)

observations := make(map[attribute.Set]int64)
Expand Down Expand Up @@ -1644,7 +1645,13 @@ func TestObservableExample(t *testing.T) {
collect := func(t *testing.T) {
t.Helper()
got := metricdata.ResourceMetrics{}
err := reader.Collect(context.Background(), &got)
err := reader1.Collect(context.Background(), &got)
require.NoError(t, err)
require.Len(t, got.ScopeMetrics, 1)
metricdatatest.AssertEqual(t, *want, got.ScopeMetrics[0], metricdatatest.IgnoreTimestamp())

got = metricdata.ResourceMetrics{}
err = reader2.Collect(context.Background(), &got)
require.NoError(t, err)
require.Len(t, got.ScopeMetrics, 1)
metricdatatest.AssertEqual(t, *want, got.ScopeMetrics[0], metricdatatest.IgnoreTimestamp())
Expand Down

0 comments on commit 13161fe

Please sign in to comment.