1
0
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:
Robert Pająk
2023-07-26 12:14:44 +02:00
committed by GitHub
parent d423bd4cf2
commit e557e74cc2
4 changed files with 22 additions and 34 deletions
+2 -2
View File
@@ -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.
+9 -15
View File
@@ -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))
})
}
}
+2 -2
View File
@@ -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.
//
+9 -15
View File
@@ -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))
})
}
}