You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-06-03 18:35:08 +02:00
Improve readers Collect docs (#4361)
This commit is contained in:
@@ -118,8 +118,8 @@ func (mr *ManualReader) Shutdown(context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Collect gathers all metrics from the SDK and other Producers, calling any
|
||||
// callbacks necessary and stores the result in rm.
|
||||
// Collect gathers all metric data related to the Reader from
|
||||
// the SDK and other Producers and stores the result in rm.
|
||||
//
|
||||
// Collect will return an error if called after shutdown.
|
||||
// Collect will return an error if rm is a nil ResourceMetrics.
|
||||
|
||||
@@ -80,25 +80,18 @@ func TestManualReaderCollect(t *testing.T) {
|
||||
defer cancel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
ctx context.Context
|
||||
resourceMetrics *metricdata.ResourceMetrics
|
||||
|
||||
name string
|
||||
ctx context.Context
|
||||
expectedErr error
|
||||
}{
|
||||
{
|
||||
name: "with a valid context",
|
||||
|
||||
ctx: context.Background(),
|
||||
resourceMetrics: &metricdata.ResourceMetrics{},
|
||||
name: "with a valid context",
|
||||
ctx: context.Background(),
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
name: "with an expired context",
|
||||
|
||||
ctx: expiredCtx,
|
||||
resourceMetrics: &metricdata.ResourceMetrics{},
|
||||
|
||||
name: "with an expired context",
|
||||
ctx: expiredCtx,
|
||||
expectedErr: context.DeadlineExceeded,
|
||||
},
|
||||
}
|
||||
@@ -117,7 +110,8 @@ func TestManualReaderCollect(t *testing.T) {
|
||||
}, testM)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, tt.expectedErr, rdr.Collect(tt.ctx, tt.resourceMetrics))
|
||||
rm := &metricdata.ResourceMetrics{}
|
||||
assert.Equal(t, tt.expectedErr, rdr.Collect(tt.ctx, rm))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,8 +237,8 @@ func (r *PeriodicReader) collectAndExport(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Collect gathers and returns all metric data related to the Reader from
|
||||
// the SDK and other Producers and stores the result in rm. The returned metric
|
||||
// Collect gathers all metric data related to the Reader from
|
||||
// the SDK and other Producers and stores the result in rm. The metric
|
||||
// data is not exported to the configured exporter, it is left to the caller to
|
||||
// handle that if desired.
|
||||
//
|
||||
|
||||
@@ -424,25 +424,18 @@ func TestPeriodicReaderCollect(t *testing.T) {
|
||||
defer cancel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
ctx context.Context
|
||||
resourceMetrics *metricdata.ResourceMetrics
|
||||
|
||||
name string
|
||||
ctx context.Context
|
||||
expectedErr error
|
||||
}{
|
||||
{
|
||||
name: "with a valid context",
|
||||
|
||||
ctx: context.Background(),
|
||||
resourceMetrics: &metricdata.ResourceMetrics{},
|
||||
name: "with a valid context",
|
||||
ctx: context.Background(),
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
name: "with an expired context",
|
||||
|
||||
ctx: expiredCtx,
|
||||
resourceMetrics: &metricdata.ResourceMetrics{},
|
||||
|
||||
name: "with an expired context",
|
||||
ctx: expiredCtx,
|
||||
expectedErr: context.DeadlineExceeded,
|
||||
},
|
||||
}
|
||||
@@ -461,7 +454,8 @@ func TestPeriodicReaderCollect(t *testing.T) {
|
||||
}, testM)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, tt.expectedErr, rdr.Collect(tt.ctx, tt.resourceMetrics))
|
||||
rm := &metricdata.ResourceMetrics{}
|
||||
assert.Equal(t, tt.expectedErr, rdr.Collect(tt.ctx, rm))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user