Skip to content

Commit

Permalink
fold reader package into top-level
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua MacDonald committed May 3, 2022
1 parent fb29c44 commit 7de2e7b
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 47 deletions.
15 changes: 7 additions & 8 deletions sdk/metric/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()

Expand All @@ -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()

Expand All @@ -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()

Expand All @@ -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()

Expand All @@ -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()

Expand All @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion sdk/metric/reader/manual.go → sdk/metric/manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions sdk/metric/metrictest/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion sdk/metric/reader/periodic.go → sdk/metric/periodic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 3 additions & 4 deletions sdk/metric/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -22,7 +21,7 @@ import (
type (
Config struct {
res *resource.Resource
readers []reader.Reader
readers []Reader
views []*view.Views
}

Expand Down Expand Up @@ -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...))
Expand All @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions sdk/metric/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion sdk/metric/reader/reader.go → sdk/metric/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
27 changes: 0 additions & 27 deletions sdk/metric/reader/doc.go

This file was deleted.

0 comments on commit 7de2e7b

Please sign in to comment.