Skip to content

Commit

Permalink
Merge branch 'main' into semconv-v1.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared committed Jul 26, 2023
2 parents 848d6c7 + d5d6318 commit da596b0
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 47 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ It provides a set of APIs to directly measure performance and behavior of your s
[Go: Metric SDK (GA)]: https://github.com/orgs/open-telemetry/projects/34

- [1]: [Metrics API](https://pkg.go.dev/go.opentelemetry.io/otel/metric) is Stable. [Metrics SDK](https://pkg.go.dev/go.opentelemetry.io/otel/sdk/metric) is Beta.
- [2]: The Logs signal development is halted for this project while we stablize the Metrics SDK.
- [2]: The Logs signal development is halted for this project while we stabilize the Metrics SDK.
No Logs Pull Requests are currently being accepted.

Progress and status specific to this repository is tracked in our
Expand Down
4 changes: 2 additions & 2 deletions sdk/metric/manual_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 9 additions & 15 deletions sdk/metric/manual_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
Expand All @@ -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))
})
}
}
4 changes: 2 additions & 2 deletions sdk/metric/periodic_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
24 changes: 9 additions & 15 deletions sdk/metric/periodic_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
Expand All @@ -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))
})
}
}
12 changes: 0 additions & 12 deletions sdk/trace/batch_span_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,18 +549,6 @@ func (indefiniteExporter) ExportSpans(ctx context.Context, _ []sdktrace.ReadOnly
return ctx.Err()
}

func TestBatchSpanProcessorForceFlushTimeout(t *testing.T) {
// Add timeout to context to test deadline
ctx, cancel := context.WithTimeout(context.Background(), time.Nanosecond)
defer cancel()
<-ctx.Done()

bsp := sdktrace.NewBatchSpanProcessor(indefiniteExporter{})
if got, want := bsp.ForceFlush(ctx), context.DeadlineExceeded; !errors.Is(got, want) {
t.Errorf("expected %q error, got %v", want, got)
}
}

func TestBatchSpanProcessorForceFlushCancellation(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
// Cancel the context
Expand Down

0 comments on commit da596b0

Please sign in to comment.