Skip to content

Commit

Permalink
Remove sdk/export/metric module, embed into the sdk/metric
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Dec 13, 2021
1 parent aedef05 commit faf0e47
Show file tree
Hide file tree
Showing 65 changed files with 776 additions and 589 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Deprecated

- Deprecate module `"go.opentelemetry.io/otel/sdk/export/metric"`, new functionality available in "go.opentelemetry.io/otel/sdk/metric" module:
- Import path changed `import "go.opentelemetry.io/otel/sdk/export/metric"` to `import go.opentelemetry.io/otel/sdk/metric/export` (#2382).

## [1.3.0] - 2021-12-10

### ⚠️ Notice ⚠️
Expand Down
2 changes: 1 addition & 1 deletion bridge/opencensus/aggregation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"go.opencensus.io/metric/metricdata"

"go.opentelemetry.io/otel/metric/number"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion bridge/opencensus/aggregation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"go.opencensus.io/metric/metricdata"

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

func TestNewAggregationFromPoints(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions bridge/opencensus/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
"go.opentelemetry.io/otel/metric/number"
"go.opentelemetry.io/otel/metric/sdkapi"
"go.opentelemetry.io/otel/metric/unit"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
"go.opentelemetry.io/otel/sdk/resource"
)

Expand Down
9 changes: 4 additions & 5 deletions bridge/opencensus/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ import (
"go.opentelemetry.io/otel/metric/number"
"go.opentelemetry.io/otel/metric/sdkapi"
"go.opentelemetry.io/otel/metric/unit"
export "go.opentelemetry.io/otel/sdk/export/metric"
exportmetric "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/metric/controller/controllertest"
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
"go.opentelemetry.io/otel/sdk/resource"
)

Expand All @@ -46,9 +45,9 @@ type fakeExporter struct {
err error
}

func (f *fakeExporter) Export(ctx context.Context, res *resource.Resource, ilr exportmetric.InstrumentationLibraryReader) error {
func (f *fakeExporter) Export(ctx context.Context, res *resource.Resource, ilr export.InstrumentationLibraryReader) error {
return controllertest.ReadAll(ilr, aggregation.StatelessTemporalitySelector(),
func(_ instrumentation.Library, record exportmetric.Record) error {
func(_ instrumentation.Library, record export.Record) error {
f.resource = res
f.records = append(f.records, record)
return f.err
Expand Down
1 change: 0 additions & 1 deletion bridge/opencensus/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
go.opentelemetry.io/otel v1.3.0
go.opentelemetry.io/otel/metric v0.26.0
go.opentelemetry.io/otel/sdk v1.3.0
go.opentelemetry.io/otel/sdk/export/metric v0.26.0
go.opentelemetry.io/otel/sdk/metric v0.26.0
go.opentelemetry.io/otel/trace v1.3.0
)
Expand Down
2 changes: 1 addition & 1 deletion example/opencensus/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.26.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.3.0
go.opentelemetry.io/otel/sdk v1.3.0
go.opentelemetry.io/otel/sdk/export/metric v0.26.0
go.opentelemetry.io/otel/sdk/metric v0.26.0
)

replace go.opentelemetry.io/otel/bridge/opentracing => ../../bridge/opentracing
Expand Down
4 changes: 2 additions & 2 deletions example/opencensus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"go.opentelemetry.io/otel/bridge/opencensus"
"go.opentelemetry.io/otel/exporters/stdout/stdoutmetric"
"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
otmetricexport "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/metric/export"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

Expand Down Expand Up @@ -100,7 +100,7 @@ func tracing(otExporter sdktrace.SpanExporter) {
// monitoring demonstrates creating an IntervalReader using the OpenTelemetry
// exporter to send metrics to the exporter by using either an OpenCensus
// registry or an OpenCensus view.
func monitoring(otExporter otmetricexport.Exporter) {
func monitoring(otExporter export.Exporter) {
log.Println("Using the OpenTelemetry stdoutmetric exporter to export OpenCensus metrics. This allows routing telemetry from both OpenTelemetry and OpenCensus to a single exporter.")
ocExporter := opencensus.NewMetricExporter(otExporter)
intervalReader, err := metricexport.NewIntervalReader(&metricexport.Reader{}, ocExporter)
Expand Down
1 change: 0 additions & 1 deletion example/prometheus/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require (
go.opentelemetry.io/otel v1.3.0
go.opentelemetry.io/otel/exporters/prometheus v0.26.0
go.opentelemetry.io/otel/metric v0.26.0
go.opentelemetry.io/otel/sdk/export/metric v0.26.0
go.opentelemetry.io/otel/sdk/metric v0.26.0
)

Expand Down
2 changes: 1 addition & 1 deletion example/prometheus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"go.opentelemetry.io/otel/exporters/prometheus"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/global"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/aggregator/histogram"
controller "go.opentelemetry.io/otel/sdk/metric/controller/basic"
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
processor "go.opentelemetry.io/otel/sdk/metric/processor/basic"
selector "go.opentelemetry.io/otel/sdk/metric/selector/simple"
)
Expand Down
8 changes: 4 additions & 4 deletions exporters/otlp/otlpmetric/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (

"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/metrictransform"
"go.opentelemetry.io/otel/metric/sdkapi"
metricsdk "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
"go.opentelemetry.io/otel/sdk/resource"
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
)
Expand All @@ -44,7 +44,7 @@ type Exporter struct {
}

// Export exports a batch of metrics.
func (e *Exporter) Export(ctx context.Context, res *resource.Resource, ilr metricsdk.InstrumentationLibraryReader) error {
func (e *Exporter) Export(ctx context.Context, res *resource.Resource, ilr export.InstrumentationLibraryReader) error {
rm, err := metrictransform.InstrumentationLibraryReader(ctx, e, res, ilr, 1)
if err != nil {
return err
Expand Down Expand Up @@ -100,7 +100,7 @@ func (e *Exporter) TemporalityFor(descriptor *sdkapi.Descriptor, kind aggregatio
return e.temporalitySelector.TemporalityFor(descriptor, kind)
}

var _ metricsdk.Exporter = (*Exporter)(nil)
var _ export.Exporter = (*Exporter)(nil)

// New constructs a new Exporter and starts it.
func New(ctx context.Context, client Client, opts ...Option) (*Exporter, error) {
Expand Down
18 changes: 9 additions & 9 deletions exporters/otlp/otlpmetric/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ import (
"go.opentelemetry.io/otel/metric/metrictest"
"go.opentelemetry.io/otel/metric/number"
"go.opentelemetry.io/otel/metric/sdkapi"
metricsdk "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/metric/aggregator/histogram"
"go.opentelemetry.io/otel/sdk/metric/aggregator/sum"
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
"go.opentelemetry.io/otel/sdk/metric/processor/processortest"
"go.opentelemetry.io/otel/sdk/resource"
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
Expand Down Expand Up @@ -675,14 +675,14 @@ func TestStatelessAggregationTemporality(t *testing.T) {
func runMetricExportTests(t *testing.T, opts []otlpmetric.Option, res *resource.Resource, records []testRecord, expected []*metricpb.ResourceMetrics) {
exp, driver := newExporter(t, opts...)

libraryRecs := map[instrumentation.Library][]metricsdk.Record{}
libraryRecs := map[instrumentation.Library][]export.Record{}
for _, r := range records {
lcopy := make([]attribute.KeyValue, len(r.labels))
copy(lcopy, r.labels)
desc := metrictest.NewDescriptor(r.name, r.iKind, r.nKind)
labs := attribute.NewSet(lcopy...)

var agg, ckpt metricsdk.Aggregator
var agg, ckpt export.Aggregator
if r.iKind.Adding() {
sums := sum.New(2)
agg, ckpt = &sums[0], &sums[1]
Expand Down Expand Up @@ -723,7 +723,7 @@ func runMetricExportTests(t *testing.T, opts []otlpmetric.Option, res *resource.
Version: meterCfg.InstrumentationVersion(),
SchemaURL: meterCfg.SchemaURL(),
}
libraryRecs[lib] = append(libraryRecs[lib], metricsdk.NewRecord(&desc, &labs, ckpt.Aggregation(), intervalStart, intervalEnd))
libraryRecs[lib] = append(libraryRecs[lib], export.NewRecord(&desc, &labs, ckpt.Aggregation(), intervalStart, intervalEnd))
}
assert.NoError(t, exp.Export(context.Background(), res, processortest.MultiInstrumentationLibraryReader(libraryRecs)))

Expand Down Expand Up @@ -772,20 +772,20 @@ func TestEmptyMetricExport(t *testing.T) {
exp, driver := newExporter(t)

for _, test := range []struct {
records []metricsdk.Record
records []export.Record
want []*metricpb.ResourceMetrics
}{
{
[]metricsdk.Record(nil),
[]export.Record(nil),
[]*metricpb.ResourceMetrics(nil),
},
{
[]metricsdk.Record{},
[]export.Record{},
[]*metricpb.ResourceMetrics(nil),
},
} {
driver.Reset()
require.NoError(t, exp.Export(context.Background(), resource.Empty(), processortest.MultiInstrumentationLibraryReader(map[instrumentation.Library][]metricsdk.Record{
require.NoError(t, exp.Export(context.Background(), resource.Empty(), processortest.MultiInstrumentationLibraryReader(map[instrumentation.Library][]export.Record{
{
Name: testLibName,
}: test.records,
Expand Down
1 change: 0 additions & 1 deletion exporters/otlp/otlpmetric/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0
go.opentelemetry.io/otel/metric v0.26.0
go.opentelemetry.io/otel/sdk v1.3.0
go.opentelemetry.io/otel/sdk/export/metric v0.26.0
go.opentelemetry.io/otel/sdk/metric v0.26.0
go.opentelemetry.io/proto/otlp v0.11.0
google.golang.org/grpc v1.42.0
Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/otlpmetric/internal/metrictransform/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
"time"

"go.opentelemetry.io/otel/metric/number"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
"go.opentelemetry.io/otel/sdk/resource"
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
"go.opentelemetry.io/otel/metric/metrictest"
"go.opentelemetry.io/otel/metric/number"
"go.opentelemetry.io/otel/metric/sdkapi"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/aggregator/lastvalue"
"go.opentelemetry.io/otel/sdk/metric/aggregator/sum"
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
)
Expand Down
16 changes: 8 additions & 8 deletions exporters/otlp/otlpmetric/internal/otlpmetrictest/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ import (
"go.opentelemetry.io/otel/metric/metrictest"
"go.opentelemetry.io/otel/metric/number"
"go.opentelemetry.io/otel/metric/sdkapi"
exportmetric "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/metric/aggregator/sum"
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/processor/processortest"
)

// OneRecordReader is a Reader that returns just one
// filled record. It may be useful for testing driver's metrics
// export.
func OneRecordReader() exportmetric.InstrumentationLibraryReader {
func OneRecordReader() export.InstrumentationLibraryReader {
desc := metrictest.NewDescriptor(
"foo",
sdkapi.CounterInstrumentKind,
Expand All @@ -45,27 +45,27 @@ func OneRecordReader() exportmetric.InstrumentationLibraryReader {
start := time.Date(2020, time.December, 8, 19, 15, 0, 0, time.UTC)
end := time.Date(2020, time.December, 8, 19, 16, 0, 0, time.UTC)
labels := attribute.NewSet(attribute.String("abc", "def"), attribute.Int64("one", 1))
rec := exportmetric.NewRecord(&desc, &labels, agg[0].Aggregation(), start, end)
rec := export.NewRecord(&desc, &labels, agg[0].Aggregation(), start, end)

return processortest.MultiInstrumentationLibraryReader(
map[instrumentation.Library][]exportmetric.Record{
map[instrumentation.Library][]export.Record{
{
Name: "onelib",
}: {rec},
})
}

func EmptyReader() exportmetric.InstrumentationLibraryReader {
func EmptyReader() export.InstrumentationLibraryReader {
return processortest.MultiInstrumentationLibraryReader(nil)
}

// FailReader is a checkpointer that returns an error during
// ForEach.
type FailReader struct{}

var _ exportmetric.InstrumentationLibraryReader = FailReader{}
var _ export.InstrumentationLibraryReader = FailReader{}

// ForEach implements exportmetric.Reader. It always fails.
func (FailReader) ForEach(readerFunc func(instrumentation.Library, exportmetric.Reader) error) error {
// ForEach implements export.Reader. It always fails.
func (FailReader) ForEach(readerFunc func(instrumentation.Library, export.Reader) error) error {
return fmt.Errorf("fail")
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/number"
"go.opentelemetry.io/otel/metric/sdkapi"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
controller "go.opentelemetry.io/otel/sdk/metric/controller/basic"
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
processor "go.opentelemetry.io/otel/sdk/metric/processor/basic"
"go.opentelemetry.io/otel/sdk/metric/selector/simple"
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlpmetric/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package otlpmetric // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric"

import "go.opentelemetry.io/otel/sdk/export/metric/aggregation"
import "go.opentelemetry.io/otel/sdk/metric/export/aggregation"

// Option are setting options passed to an Exporter on creation.
type Option interface {
Expand Down
1 change: 0 additions & 1 deletion exporters/prometheus/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
go.opentelemetry.io/otel v1.3.0
go.opentelemetry.io/otel/metric v0.26.0
go.opentelemetry.io/otel/sdk v1.3.0
go.opentelemetry.io/otel/sdk/export/metric v0.26.0
go.opentelemetry.io/otel/sdk/metric v0.26.0
)

Expand Down
4 changes: 2 additions & 2 deletions exporters/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import (
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/number"
"go.opentelemetry.io/otel/metric/sdkapi"
export "go.opentelemetry.io/otel/sdk/export/metric"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/instrumentation"
controller "go.opentelemetry.io/otel/sdk/metric/controller/basic"
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
"go.opentelemetry.io/otel/sdk/resource"
)

Expand Down
2 changes: 1 addition & 1 deletion exporters/prometheus/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/prometheus"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/sdk/export/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/aggregator/histogram"
controller "go.opentelemetry.io/otel/sdk/metric/controller/basic"
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
processor "go.opentelemetry.io/otel/sdk/metric/processor/basic"
selector "go.opentelemetry.io/otel/sdk/metric/selector/simple"
"go.opentelemetry.io/otel/sdk/resource"
Expand Down
6 changes: 2 additions & 4 deletions exporters/stdout/stdoutmetric/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@

package stdoutmetric // import "go.opentelemetry.io/otel/exporters/stdout/stdoutmetric"

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

type Exporter struct {
metricExporter
}

var (
_ metric.Exporter = &Exporter{}
_ export.Exporter = &Exporter{}
)

// New creates an Exporter with the passed options.
Expand Down
1 change: 0 additions & 1 deletion exporters/stdout/stdoutmetric/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require (
go.opentelemetry.io/otel v1.3.0
go.opentelemetry.io/otel/metric v0.26.0
go.opentelemetry.io/otel/sdk v1.3.0
go.opentelemetry.io/otel/sdk/export/metric v0.26.0
go.opentelemetry.io/otel/sdk/metric v0.26.0
)

Expand Down
Loading

0 comments on commit faf0e47

Please sign in to comment.