Skip to content

Commit

Permalink
Move reader comparability test to var
Browse files Browse the repository at this point in the history
  • Loading branch information
MadVikingGod authored Aug 11, 2022
1 parent 75c1bdb commit 127dce7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions sdk/metric/manual_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ type manualReader struct {
aggregationSelector AggregationSelector
}

// Compile time check the manualReader implements Reader.
var _ Reader = &manualReader{}
// Compile time check the manualReader implements Reader and is comparable.
var _ = map[Reader]struct{}{&manualReader{}: {}}

// NewManualReader returns a Reader which is directly called to collect metrics.
func NewManualReader(opts ...ManualReaderOption) Reader {
Expand Down
3 changes: 3 additions & 0 deletions sdk/metric/periodic_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ type periodicReader struct {
shutdownOnce sync.Once
}

// Compile time check the periodicReader implements Reader and is comparable.
var _ = map[Reader]struct{}{&periodicReader{}: {}}

// newTicker allows testing override.
var newTicker = time.NewTicker

Expand Down
7 changes: 0 additions & 7 deletions sdk/metric/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,3 @@ func TestDefaultTemporalitySelector(t *testing.T) {
assert.Equal(t, metricdata.CumulativeTemporality, DefaultTemporalitySelector(ik))
}
}

func TestReadersAreComparable(t *testing.T) {
var _ map[Reader]struct{} = map[Reader]struct{}{
NewManualReader(): {},
NewPeriodicReader(new(fnExporter)): {},
}
}

0 comments on commit 127dce7

Please sign in to comment.