Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Package sdk/metric/export into sdk/metric/metricdata #3014

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions sdk/metric/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -45,9 +45,11 @@ func (r *reader) aggregation(kind InstrumentKind) aggregation.Aggregation { // n
return r.aggregationFunc(kind)
}

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) register(p producer) { r.producer = p }
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) }
Expand Down
4 changes: 2 additions & 2 deletions sdk/metric/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"context"
"fmt"

"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
)

// ErrExporterShutdown is returned if Export or Shutdown are called after an
Expand All @@ -41,7 +41,7 @@ type Exporter interface {
// implement any retry logic. All errors returned by this function are
// considered unrecoverable and will be reported to a configured error
// Handler.
Export(context.Context, export.ResourceMetrics) error
Export(context.Context, metricdata.ResourceMetrics) error

// ForceFlush flushes any metric data held by an exporter.
//
Expand Down
4 changes: 2 additions & 2 deletions sdk/metric/internal/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package internal // import "go.opentelemetry.io/otel/sdk/metric/internal"

import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
)

// Aggregator forms an aggregation from a collection of recorded measurements.
Expand All @@ -30,5 +30,5 @@ type Aggregator[N int64 | float64] interface {

// Aggregation returns an Aggregation, for all the aggregated
// measurements made and ends an aggregation cycle.
Aggregation() export.Aggregation
Aggregation() metricdata.Aggregation
}
4 changes: 2 additions & 2 deletions sdk/metric/internal/aggregator_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import (
"go.opentelemetry.io/otel/metric/instrument"
"go.opentelemetry.io/otel/metric/instrument/syncint64"
"go.opentelemetry.io/otel/sdk/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
)

type meter struct {
// When a reader initiates a collection, the meter would collect
// aggregations from each of these functions.
aggregations []export.Aggregation
aggregations []metricdata.Aggregation
}

func (m *meter) SyncInt64() syncint64.InstrumentProvider {
Expand Down
6 changes: 3 additions & 3 deletions sdk/metric/internal/histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package internal // import "go.opentelemetry.io/otel/sdk/metric/internal"
import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
)

// histogram summarizes a set of measurements as an histogram with
Expand Down Expand Up @@ -52,7 +52,7 @@ type deltaHistogram[N int64 | float64] struct {
// TODO(#2970): implement.
}

func (s *deltaHistogram[N]) Aggregation() export.Aggregation {
func (s *deltaHistogram[N]) Aggregation() metricdata.Aggregation {
// TODO(#2970): implement.
return nil
}
Expand All @@ -75,7 +75,7 @@ type cumulativeHistogram[N int64 | float64] struct {
// TODO(#2970): implement.
}

func (s *cumulativeHistogram[N]) Aggregation() export.Aggregation {
func (s *cumulativeHistogram[N]) Aggregation() metricdata.Aggregation {
// TODO(#2970): implement.
return nil
}
4 changes: 2 additions & 2 deletions sdk/metric/internal/lastvalue.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package internal // import "go.opentelemetry.io/otel/sdk/metric/internal"

import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
)

// lastValue summarizes a set of measurements as the last one made.
Expand All @@ -37,7 +37,7 @@ func (s *lastValue[N]) Aggregate(value N, attr attribute.Set) {
// TODO(#2971): implement.
}

func (s *lastValue[N]) Aggregation() export.Aggregation {
func (s *lastValue[N]) Aggregation() metricdata.Aggregation {
// TODO(#2971): implement.
return nil
}
6 changes: 3 additions & 3 deletions sdk/metric/internal/sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package internal // import "go.opentelemetry.io/otel/sdk/metric/internal"

import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
)

// sum summarizes a set of measurements as their arithmetic sum.
Expand Down Expand Up @@ -50,7 +50,7 @@ type deltaSum[N int64 | float64] struct {
// TODO(#2972): implement.
}

func (s *deltaSum[N]) Aggregation() export.Aggregation {
func (s *deltaSum[N]) Aggregation() metricdata.Aggregation {
// TODO(#2972): implement.
return nil
}
Expand All @@ -74,7 +74,7 @@ type cumulativeSum[N int64 | float64] struct {
// TODO(#2972): implement.
}

func (s *cumulativeSum[N]) Aggregation() export.Aggregation {
func (s *cumulativeSum[N]) Aggregation() metricdata.Aggregation {
// TODO(#2972): implement.
return nil
}
14 changes: 7 additions & 7 deletions sdk/metric/manual_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,7 +34,7 @@ type manualReader struct {
producer atomic.Value
shutdownOnce sync.Once

temporalitySelector func(InstrumentKind) export.Temporality
temporalitySelector func(InstrumentKind) metricdata.Temporality
aggregationSelector AggregationSelector
}

Expand All @@ -61,7 +61,7 @@ func (mr *manualReader) register(p producer) {
}

// temporality reports the Temporality for the instrument kind provided.
func (mr *manualReader) temporality(kind InstrumentKind) export.Temporality {
func (mr *manualReader) temporality(kind InstrumentKind) metricdata.Temporality {
return mr.temporalitySelector(kind)
}

Expand Down Expand Up @@ -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)
Expand All @@ -103,15 +103,15 @@ 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)
}

// manualReaderConfig contains configuration options for a ManualReader.
type manualReaderConfig struct {
temporalitySelector func(InstrumentKind) export.Temporality
temporalitySelector func(InstrumentKind) metricdata.Temporality
aggregationSelector AggregationSelector
}

Expand Down
14 changes: 7 additions & 7 deletions sdk/metric/manual_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"

"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
)

func TestManualReader(t *testing.T) {
Expand All @@ -34,35 +34,35 @@ func BenchmarkManualReader(b *testing.B) {
b.Run("Collect", benchReaderCollectFunc(NewManualReader()))
}

var deltaTemporalitySelector = func(InstrumentKind) export.Temporality { return export.DeltaTemporality }
var cumulativeTemporalitySelector = func(InstrumentKind) export.Temporality { return export.CumulativeTemporality }
var deltaTemporalitySelector = func(InstrumentKind) metricdata.Temporality { return metricdata.DeltaTemporality }
var cumulativeTemporalitySelector = func(InstrumentKind) metricdata.Temporality { return metricdata.CumulativeTemporality }

func TestManualReaderTemporality(t *testing.T) {
tests := []struct {
name string
options []ManualReaderOption
// Currently only testing constant temporality. This should be expanded
// if we put more advanced selection in the SDK
wantTemporality export.Temporality
wantTemporality metricdata.Temporality
}{
{
name: "default",
wantTemporality: export.CumulativeTemporality,
wantTemporality: metricdata.CumulativeTemporality,
},
{
name: "delta",
options: []ManualReaderOption{
WithTemporalitySelector(deltaTemporalitySelector),
},
wantTemporality: export.DeltaTemporality,
wantTemporality: metricdata.DeltaTemporality,
},
{
name: "repeats overwrite",
options: []ManualReaderOption{
WithTemporalitySelector(deltaTemporalitySelector),
WithTemporalitySelector(cumulativeTemporalitySelector),
},
wantTemporality: export.CumulativeTemporality,
wantTemporality: metricdata.CumulativeTemporality,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// TODO: NOTE this is a temporary space, it may be moved following the
// discussion of #2813, or #2841

package export // import "go.opentelemetry.io/otel/sdk/metric/export"
package metricdata // import "go.opentelemetry.io/otel/sdk/metric/metricdata"

import (
"time"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//go:build go1.17
// +build go1.17

package export // import "go.opentelemetry.io/otel/sdk/metric/export"
package metricdata // import "go.opentelemetry.io/otel/sdk/metric/metricdata"

// Temporality defines the window that an aggregation was calculated over.
type Temporality uint8
Expand Down
14 changes: 7 additions & 7 deletions sdk/metric/periodic_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -40,7 +40,7 @@ const (
type periodicReaderConfig struct {
interval time.Duration
timeout time.Duration
temporalitySelector func(InstrumentKind) export.Temporality
temporalitySelector func(InstrumentKind) metricdata.Temporality
aggregationSelector AggregationSelector
}

Expand Down Expand Up @@ -140,7 +140,7 @@ type periodicReader struct {
timeout time.Duration
exporter Exporter

temporalitySelector func(InstrumentKind) export.Temporality
temporalitySelector func(InstrumentKind) metricdata.Temporality
aggregationSelector AggregationSelector

wg sync.WaitGroup
Expand Down Expand Up @@ -185,7 +185,7 @@ func (r *periodicReader) register(p producer) {
}

// temporality reports the Temporality for the instrument kind provided.
func (r *periodicReader) temporality(kind InstrumentKind) export.Temporality {
func (r *periodicReader) temporality(kind InstrumentKind) metricdata.Temporality {
return r.temporalitySelector(kind)
}

Expand All @@ -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)
Expand All @@ -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)
}
Expand Down
Loading