From 14392d137e9ece30e9959a5d8a354ed4c9883b01 Mon Sep 17 00:00:00 2001 From: csuzhang Date: Wed, 13 Jul 2022 22:15:24 +0800 Subject: [PATCH] fix quote code --- sdk/metric/config_test.go | 10 +++++----- sdk/metric/manual_reader.go | 8 ++++---- sdk/metric/periodic_reader.go | 8 ++++---- sdk/metric/periodic_reader_test.go | 10 +++++----- sdk/metric/reader.go | 12 ++++++------ sdk/metric/reader_test.go | 16 ++++++++-------- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/sdk/metric/config_test.go b/sdk/metric/config_test.go index 6f0d5c665d7..8683a421a4b 100644 --- a/sdk/metric/config_test.go +++ b/sdk/metric/config_test.go @@ -26,15 +26,15 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/sdk/metric/aggregation" - "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/metricdata" "go.opentelemetry.io/otel/sdk/resource" ) type reader struct { producer producer - temporalityFunc func(InstrumentKind) export.Temporality + temporalityFunc func(InstrumentKind) metricdata.Temporality aggregationFunc AggregationSelector - collectFunc func(context.Context) (export.ResourceMetrics, error) + collectFunc func(context.Context) (metricdata.ResourceMetrics, error) forceFlushFunc func(context.Context) error shutdownFunc func(context.Context) error } @@ -46,8 +46,8 @@ func (r *reader) aggregation(kind InstrumentKind) aggregation.Aggregation { // n } func (r *reader) register(p producer) { r.producer = p } -func (r *reader) temporality(kind InstrumentKind) export.Temporality { return r.temporalityFunc(kind) } -func (r *reader) Collect(ctx context.Context) (export.ResourceMetrics, error) { +func (r *reader) temporality(kind InstrumentKind) metricdata.Temporality { return r.temporalityFunc(kind) } +func (r *reader) Collect(ctx context.Context) (metricdata.ResourceMetrics, error) { return r.collectFunc(ctx) } func (r *reader) ForceFlush(ctx context.Context) error { return r.forceFlushFunc(ctx) } diff --git a/sdk/metric/manual_reader.go b/sdk/metric/manual_reader.go index 46728a485e3..1d5b5457527 100644 --- a/sdk/metric/manual_reader.go +++ b/sdk/metric/manual_reader.go @@ -25,7 +25,7 @@ import ( "go.opentelemetry.io/otel/internal/global" "go.opentelemetry.io/otel/sdk/metric/aggregation" - "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/metricdata" ) // manualReader is a a simple Reader that allows an application to @@ -90,10 +90,10 @@ func (mr *manualReader) Shutdown(context.Context) error { // Collect gathers all metrics from the SDK, calling any callbacks necessary. // Collect will return an error if called after shutdown. -func (mr *manualReader) Collect(ctx context.Context) (export.ResourceMetrics, error) { +func (mr *manualReader) Collect(ctx context.Context) (metricdata.ResourceMetrics, error) { p := mr.producer.Load() if p == nil { - return export.ResourceMetrics{}, ErrReaderNotRegistered + return metricdata.ResourceMetrics{}, ErrReaderNotRegistered } ph, ok := p.(produceHolder) @@ -103,7 +103,7 @@ func (mr *manualReader) Collect(ctx context.Context) (export.ResourceMetrics, er // happen, return an error instead of panicking so a users code does // not halt in the processes. err := fmt.Errorf("manual reader: invalid producer: %T", p) - return export.ResourceMetrics{}, err + return metricdata.ResourceMetrics{}, err } return ph.produce(ctx) diff --git a/sdk/metric/periodic_reader.go b/sdk/metric/periodic_reader.go index b227a47ba4f..1fb605b7c30 100644 --- a/sdk/metric/periodic_reader.go +++ b/sdk/metric/periodic_reader.go @@ -27,7 +27,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/internal/global" "go.opentelemetry.io/otel/sdk/metric/aggregation" - "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/metricdata" ) // Default periodic reader timing. @@ -199,10 +199,10 @@ func (r *periodicReader) aggregation(kind InstrumentKind) aggregation.Aggregatio // exporter, it is left to the caller to handle that if desired. // // An error is returned if this is called after Shutdown. -func (r *periodicReader) Collect(ctx context.Context) (export.ResourceMetrics, error) { +func (r *periodicReader) Collect(ctx context.Context) (metricdata.ResourceMetrics, error) { p := r.producer.Load() if p == nil { - return export.ResourceMetrics{}, ErrReaderNotRegistered + return metricdata.ResourceMetrics{}, ErrReaderNotRegistered } ph, ok := p.(produceHolder) @@ -212,7 +212,7 @@ func (r *periodicReader) Collect(ctx context.Context) (export.ResourceMetrics, e // happen, return an error instead of panicking so a users code does // not halt in the processes. err := fmt.Errorf("periodic reader: invalid producer: %T", p) - return export.ResourceMetrics{}, err + return metricdata.ResourceMetrics{}, err } return ph.produce(ctx) } diff --git a/sdk/metric/periodic_reader_test.go b/sdk/metric/periodic_reader_test.go index 54b7c39e9a0..1171c171e91 100644 --- a/sdk/metric/periodic_reader_test.go +++ b/sdk/metric/periodic_reader_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/suite" "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/metricdata" ) const testDur = time.Second * 2 @@ -56,14 +56,14 @@ func TestWithInterval(t *testing.T) { } type fnExporter struct { - exportFunc func(context.Context, export.ResourceMetrics) error + exportFunc func(context.Context, metricdata.ResourceMetrics) error flushFunc func(context.Context) error shutdownFunc func(context.Context) error } var _ Exporter = (*fnExporter)(nil) -func (e *fnExporter) Export(ctx context.Context, m export.ResourceMetrics) error { +func (e *fnExporter) Export(ctx context.Context, m metricdata.ResourceMetrics) error { if e.exportFunc != nil { return e.exportFunc(ctx, m) } @@ -94,7 +94,7 @@ func (ts *periodicReaderTestSuite) SetupTest() { ts.readerTestSuite.SetupTest() e := &fnExporter{ - exportFunc: func(context.Context, export.ResourceMetrics) error { return assert.AnError }, + exportFunc: func(context.Context, metricdata.ResourceMetrics) error { return assert.AnError }, flushFunc: func(context.Context) error { return assert.AnError }, shutdownFunc: func(context.Context) error { return assert.AnError }, } @@ -163,7 +163,7 @@ func TestPeriodicReaderRun(t *testing.T) { otel.SetErrorHandler(eh) exp := &fnExporter{ - exportFunc: func(_ context.Context, m export.ResourceMetrics) error { + exportFunc: func(_ context.Context, m metricdata.ResourceMetrics) error { // The testProducer produces testMetrics. assert.Equal(t, testMetrics, m) return assert.AnError diff --git a/sdk/metric/reader.go b/sdk/metric/reader.go index dbbb25986be..c9b9d8f84dd 100644 --- a/sdk/metric/reader.go +++ b/sdk/metric/reader.go @@ -23,7 +23,7 @@ import ( "go.opentelemetry.io/otel/internal/global" "go.opentelemetry.io/otel/sdk/metric/aggregation" - "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/metricdata" ) // errDuplicateRegister is logged by a Reader when an attempt to registered it @@ -65,7 +65,7 @@ type Reader interface { // Collect gathers and returns all metric data related to the Reader from // the SDK. An error is returned if this is called after Shutdown. - Collect(context.Context) (export.ResourceMetrics, error) + Collect(context.Context) (metricdata.ResourceMetrics, error) // ForceFlush flushes all metric measurements held in an export pipeline. // @@ -93,21 +93,21 @@ type producer interface { // produce returns aggregated metrics from a single collection. // // This method is safe to call concurrently. - produce(context.Context) (export.ResourceMetrics, error) + produce(context.Context) (metricdata.ResourceMetrics, error) } // produceHolder is used as an atomic.Value to wrap the non-concrete producer // type. type produceHolder struct { - produce func(context.Context) (export.ResourceMetrics, error) + produce func(context.Context) (metricdata.ResourceMetrics, error) } // shutdownProducer produces an ErrReaderShutdown error always. type shutdownProducer struct{} // produce returns an ErrReaderShutdown error. -func (p shutdownProducer) produce(context.Context) (export.ResourceMetrics, error) { - return export.ResourceMetrics{}, ErrReaderShutdown +func (p shutdownProducer) produce(context.Context) (metricdata.ResourceMetrics, error) { + return metricdata.ResourceMetrics{}, ErrReaderShutdown } // ReaderOption applies a configuration option value to either a ManualReader or diff --git a/sdk/metric/reader_test.go b/sdk/metric/reader_test.go index 41d8e5c6088..17f668dd242 100644 --- a/sdk/metric/reader_test.go +++ b/sdk/metric/reader_test.go @@ -27,7 +27,7 @@ import ( "github.com/stretchr/testify/suite" "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/metricdata" ) type readerTestSuite struct { @@ -69,7 +69,7 @@ func (ts *readerTestSuite) TestCollectAfterShutdown() { m, err := ts.Reader.Collect(ctx) ts.ErrorIs(err, ErrReaderShutdown) - ts.Equal(export.ResourceMetrics{}, m) + ts.Equal(metricdata.ResourceMetrics{}, m) } func (ts *readerTestSuite) TestShutdownTwice() { @@ -88,7 +88,7 @@ func (ts *readerTestSuite) TestMultipleForceFlush() { func (ts *readerTestSuite) TestMultipleRegister() { p0 := testProducer{ - produceFunc: func(ctx context.Context) (export.ResourceMetrics, error) { + produceFunc: func(ctx context.Context) (metricdata.ResourceMetrics, error) { // Differentiate this producer from the second by returning an // error. return testMetrics, assert.AnError @@ -143,18 +143,18 @@ func (ts *readerTestSuite) TestShutdownBeforeRegister() { m, err := ts.Reader.Collect(ctx) ts.ErrorIs(err, ErrReaderShutdown) - ts.Equal(export.ResourceMetrics{}, m) + ts.Equal(metricdata.ResourceMetrics{}, m) } -var testMetrics = export.ResourceMetrics{ +var testMetrics = metricdata.ResourceMetrics{ // TODO: test with actual data. } type testProducer struct { - produceFunc func(context.Context) (export.ResourceMetrics, error) + produceFunc func(context.Context) (metricdata.ResourceMetrics, error) } -func (p testProducer) produce(ctx context.Context) (export.ResourceMetrics, error) { +func (p testProducer) produce(ctx context.Context) (metricdata.ResourceMetrics, error) { if p.produceFunc != nil { return p.produceFunc(ctx) } @@ -168,7 +168,7 @@ func benchReaderCollectFunc(r Reader) func(*testing.B) { // Store bechmark results in a closure to prevent the compiler from // inlining and skipping the function. var ( - collectedMetrics export.ResourceMetrics + collectedMetrics metricdata.ResourceMetrics err error )