diff --git a/sdk/metric/benchmark_test.go b/sdk/metric/benchmark_test.go index 5b8755e8585c..8b19d7e79521 100644 --- a/sdk/metric/benchmark_test.go +++ b/sdk/metric/benchmark_test.go @@ -6,12 +6,11 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/sdk/metric/data" - "go.opentelemetry.io/otel/sdk/metric/reader" ) func BenchmarkCounterAddNoAttrs(b *testing.B) { ctx := context.Background() - rdr := reader.NewManualReader("bench") + rdr := NewManualReader("bench") provider := New(WithReader(rdr)) b.ReportAllocs() @@ -28,7 +27,7 @@ func BenchmarkCounterAddNoAttrs(b *testing.B) { // 3. an attribute array (map key) func BenchmarkCounterAddOneAttr(b *testing.B) { ctx := context.Background() - rdr := reader.NewManualReader("bench") + rdr := NewManualReader("bench") provider := New(WithReader(rdr)) b.ReportAllocs() @@ -52,7 +51,7 @@ func BenchmarkCounterAddOneAttr(b *testing.B) { // 10. an output Aggregator func BenchmarkCounterAddManyAttrs(b *testing.B) { ctx := context.Background() - rdr := reader.NewManualReader("bench") + rdr := NewManualReader("bench") provider := New(WithReader(rdr)) b.ReportAllocs() @@ -65,7 +64,7 @@ func BenchmarkCounterAddManyAttrs(b *testing.B) { func BenchmarkCounterCollectOneAttrNoReuse(b *testing.B) { ctx := context.Background() - rdr := reader.NewManualReader("bench") + rdr := NewManualReader("bench") provider := New(WithReader(rdr)) b.ReportAllocs() @@ -80,7 +79,7 @@ func BenchmarkCounterCollectOneAttrNoReuse(b *testing.B) { func BenchmarkCounterCollectOneAttrWithReuse(b *testing.B) { ctx := context.Background() - rdr := reader.NewManualReader("bench") + rdr := NewManualReader("bench") provider := New(WithReader(rdr)) b.ReportAllocs() @@ -97,7 +96,7 @@ func BenchmarkCounterCollectOneAttrWithReuse(b *testing.B) { func BenchmarkCounterCollectTenAttrs(b *testing.B) { ctx := context.Background() - rdr := reader.NewManualReader("bench") + rdr := NewManualReader("bench") provider := New(WithReader(rdr)) b.ReportAllocs() @@ -115,7 +114,7 @@ func BenchmarkCounterCollectTenAttrs(b *testing.B) { func BenchmarkCounterCollectTenAttrsTenTimes(b *testing.B) { ctx := context.Background() - rdr := reader.NewManualReader("bench") + rdr := NewManualReader("bench") provider := New(WithReader(rdr)) b.ReportAllocs() diff --git a/sdk/metric/reader/manual.go b/sdk/metric/manual.go similarity index 95% rename from sdk/metric/reader/manual.go rename to sdk/metric/manual.go index 962592c67119..3d21053d5e1e 100644 --- a/sdk/metric/reader/manual.go +++ b/sdk/metric/manual.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package reader // import "go.opentelemetry.io/otel/sdk/metric/reader" +package metric // import "go.opentelemetry.io/otel/sdk/metric" import ( "context" diff --git a/sdk/metric/metrictest/exporter.go b/sdk/metric/metrictest/exporter.go index 9d84678b64fd..7ec427bc6e10 100644 --- a/sdk/metric/metrictest/exporter.go +++ b/sdk/metric/metrictest/exporter.go @@ -26,7 +26,6 @@ import ( "go.opentelemetry.io/otel/sdk/metric/aggregator/aggregation" "go.opentelemetry.io/otel/sdk/metric/data" "go.opentelemetry.io/otel/sdk/metric/number" - "go.opentelemetry.io/otel/sdk/metric/reader" "go.opentelemetry.io/otel/sdk/metric/view" ) @@ -39,13 +38,13 @@ import ( type Exporter struct { // Records contains the last metrics collected. Records []ExportRecord - reader *reader.ManualReader + reader *sdkmetric.ManualReader } // NewTestMeterProvider creates a MeterProvider and Exporter to be used in tests. func NewTestMeterProvider(opts ...Option) (metric.MeterProvider, *Exporter) { exp := &Exporter{ - reader: reader.NewManualReader("inmemory"), + reader: sdkmetric.NewManualReader("inmemory"), } cfg := newConfig(opts...) sdk := sdkmetric.New( diff --git a/sdk/metric/reader/periodic.go b/sdk/metric/periodic.go similarity index 98% rename from sdk/metric/reader/periodic.go rename to sdk/metric/periodic.go index 836335843f2f..3d1ff991eebc 100644 --- a/sdk/metric/reader/periodic.go +++ b/sdk/metric/periodic.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package reader // import "go.opentelemetry.io/otel/sdk/metric/reader" +package metric // import "go.opentelemetry.io/otel/sdk/metric" import ( "context" diff --git a/sdk/metric/provider.go b/sdk/metric/provider.go index e7d47cf6c135..68be5d41acf0 100644 --- a/sdk/metric/provider.go +++ b/sdk/metric/provider.go @@ -13,7 +13,6 @@ import ( "go.opentelemetry.io/otel/sdk/metric/internal/asyncstate" "go.opentelemetry.io/otel/sdk/metric/internal/viewstate" "go.opentelemetry.io/otel/sdk/metric/number" - "go.opentelemetry.io/otel/sdk/metric/reader" "go.opentelemetry.io/otel/sdk/metric/sdkinstrument" "go.opentelemetry.io/otel/sdk/metric/view" "go.opentelemetry.io/otel/sdk/resource" @@ -22,7 +21,7 @@ import ( type ( Config struct { res *resource.Resource - readers []reader.Reader + readers []Reader views []*view.Views } @@ -72,7 +71,7 @@ func WithResource(res *resource.Resource) Option { } } -func WithReader(r reader.Reader, opts ...view.Option) Option { +func WithReader(r Reader, opts ...view.Option) Option { return func(cfg *Config) { cfg.readers = append(cfg.readers, r) cfg.views = append(cfg.views, view.New(r.String(), opts...)) @@ -98,7 +97,7 @@ func New(opts ...Option) *Provider { return p } -func (p *Provider) producerFor(ep data.Pipeline) reader.Producer { +func (p *Provider) producerFor(ep data.Pipeline) Producer { return &providerProducer{ provider: p, pipe: ep, diff --git a/sdk/metric/provider_test.go b/sdk/metric/provider_test.go index 55930c66c910..7dfac6e0c441 100644 --- a/sdk/metric/provider_test.go +++ b/sdk/metric/provider_test.go @@ -6,14 +6,13 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/sdk/metric/data" - "go.opentelemetry.io/otel/sdk/metric/reader" ) // TODO: incomplete func TestOutputReuse(t *testing.T) { ctx := context.Background() - rdr := reader.NewManualReader("test") + rdr := NewManualReader("test") provider := New(WithReader(rdr)) cntr, _ := provider.Meter("test").SyncInt64().Counter("hello") diff --git a/sdk/metric/reader/reader.go b/sdk/metric/reader.go similarity index 96% rename from sdk/metric/reader/reader.go rename to sdk/metric/reader.go index 66425eaf538c..9acc121cd3f0 100644 --- a/sdk/metric/reader/reader.go +++ b/sdk/metric/reader.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package reader // import "go.opentelemetry.io/otel/sdk/metric/reader" +package metric // import "go.opentelemetry.io/otel/sdk/metric" import ( "context" diff --git a/sdk/metric/reader/doc.go b/sdk/metric/reader/doc.go deleted file mode 100644 index 638c88cef687..000000000000 --- a/sdk/metric/reader/doc.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/* - Package reader contains support for binding a Metric Exporter to the - OpenTelemetry metrics SDK. It contains: - - - `Config` (struct) holds the Reader's configured Views and other Defaults - - `Exporter` (interface) is how the SDK acts upon the Reader (e.g., Flush, Shutdown) - - `Producer` (interface) is how the Reader acts upon the SDK (e.g., Collect) - - Metrics data objects: `Sequence`, `Metrics`, `Scope`, `Instrument`, and `Point` structs - - Functional options for building `Config` structs - - Standard selectors for aggregation kind and temporality - - Helper functions that support data object re-use (Reset, Reallocate). -*/ -package reader // import "go.opentelemetry.io/otel/sdk/metric/reader"