From 3f91b9eeb4dc8f1b5e938fd41d52a75ea65a8fa8 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Mon, 13 Dec 2021 10:59:36 -0800 Subject: [PATCH] Remove sdk/export/metric module, embed into the sdk/metric Signed-off-by: Bogdan Drutu --- CHANGELOG.md | 5 + bridge/opencensus/aggregation.go | 2 +- bridge/opencensus/aggregation_test.go | 2 +- bridge/opencensus/exporter.go | 4 +- bridge/opencensus/exporter_test.go | 9 +- bridge/opencensus/go.mod | 1 - example/opencensus/go.mod | 2 +- example/opencensus/main.go | 4 +- example/prometheus/go.mod | 1 - example/prometheus/main.go | 2 +- exporters/otlp/otlpmetric/exporter.go | 8 +- exporters/otlp/otlpmetric/exporter_test.go | 18 +- exporters/otlp/otlpmetric/go.mod | 1 - .../internal/metrictransform/metric.go | 4 +- .../internal/metrictransform/metric_test.go | 4 +- .../internal/otlpmetrictest/data.go | 16 +- .../internal/otlpmetrictest/otlptest.go | 2 +- exporters/otlp/otlpmetric/options.go | 2 +- exporters/prometheus/go.mod | 1 - exporters/prometheus/prometheus.go | 4 +- exporters/prometheus/prometheus_test.go | 2 +- exporters/stdout/stdoutmetric/exporter.go | 6 +- exporters/stdout/stdoutmetric/go.mod | 1 - exporters/stdout/stdoutmetric/metric.go | 12 +- exporters/stdout/stdoutmetric/metric_test.go | 2 +- sdk/export/metric/aggregation/aggregation.go | 135 ++----- sdk/export/metric/aggregation/temporality.go | 96 +---- sdk/export/metric/go.mod | 4 +- sdk/export/metric/go.sum | 2 +- sdk/export/metric/metric.go | 332 ++--------------- sdk/metric/aggregator/aggregator.go | 4 +- sdk/metric/aggregator/aggregator_test.go | 2 +- sdk/metric/aggregator/aggregatortest/test.go | 4 +- sdk/metric/aggregator/histogram/histogram.go | 4 +- .../aggregator/histogram/histogram_test.go | 2 +- sdk/metric/aggregator/lastvalue/lastvalue.go | 4 +- .../aggregator/lastvalue/lastvalue_test.go | 4 +- sdk/metric/aggregator/sum/sum.go | 4 +- sdk/metric/aggregator/sum/sum_test.go | 2 +- sdk/metric/benchmark_test.go | 2 +- sdk/metric/controller/basic/config.go | 2 +- sdk/metric/controller/basic/controller.go | 2 +- .../controller/basic/controller_test.go | 4 +- sdk/metric/controller/basic/pull_test.go | 2 +- sdk/metric/controller/basic/push_test.go | 4 +- sdk/metric/controller/controllertest/test.go | 4 +- sdk/metric/correct_test.go | 4 +- sdk/metric/doc.go | 2 +- sdk/metric/export/aggregation/aggregation.go | 131 +++++++ sdk/metric/export/aggregation/temporality.go | 117 ++++++ .../export}/aggregation/temporality_string.go | 0 .../export}/aggregation/temporality_test.go | 0 sdk/metric/export/metric.go | 343 ++++++++++++++++++ .../metric => metric/export}/metric_test.go | 2 +- sdk/metric/go.mod | 1 - sdk/metric/processor/basic/basic.go | 4 +- sdk/metric/processor/basic/basic_test.go | 4 +- sdk/metric/processor/processortest/test.go | 4 +- .../processor/processortest/test_test.go | 4 +- sdk/metric/processor/reducer/reducer.go | 2 +- sdk/metric/processor/reducer/reducer_test.go | 2 +- sdk/metric/sdk.go | 2 +- sdk/metric/selector/simple/simple.go | 2 +- sdk/metric/selector/simple/simple_test.go | 2 +- sdk/metric/stress_test.go | 4 +- 65 files changed, 776 insertions(+), 588 deletions(-) create mode 100644 sdk/metric/export/aggregation/aggregation.go create mode 100644 sdk/metric/export/aggregation/temporality.go rename sdk/{export/metric => metric/export}/aggregation/temporality_string.go (100%) rename sdk/{export/metric => metric/export}/aggregation/temporality_test.go (100%) create mode 100644 sdk/metric/export/metric.go rename sdk/{export/metric => metric/export}/metric_test.go (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6665b12def0..57c8612379a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ⚠️ diff --git a/bridge/opencensus/aggregation.go b/bridge/opencensus/aggregation.go index 10616b993aa..3d88f7589a4 100644 --- a/bridge/opencensus/aggregation.go +++ b/bridge/opencensus/aggregation.go @@ -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 ( diff --git a/bridge/opencensus/aggregation_test.go b/bridge/opencensus/aggregation_test.go index dbd9d69b827..13093c67336 100644 --- a/bridge/opencensus/aggregation_test.go +++ b/bridge/opencensus/aggregation_test.go @@ -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) { diff --git a/bridge/opencensus/exporter.go b/bridge/opencensus/exporter.go index 1720c67f21f..bdc22eced73 100644 --- a/bridge/opencensus/exporter.go +++ b/bridge/opencensus/exporter.go @@ -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" ) diff --git a/bridge/opencensus/exporter_test.go b/bridge/opencensus/exporter_test.go index 0910cb5720b..8fe6893477e 100644 --- a/bridge/opencensus/exporter_test.go +++ b/bridge/opencensus/exporter_test.go @@ -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" ) @@ -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 diff --git a/bridge/opencensus/go.mod b/bridge/opencensus/go.mod index 6dd08623d08..30a69366c61 100644 --- a/bridge/opencensus/go.mod +++ b/bridge/opencensus/go.mod @@ -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 ) diff --git a/example/opencensus/go.mod b/example/opencensus/go.mod index 0c3e02ac4eb..a1fb87122a0 100644 --- a/example/opencensus/go.mod +++ b/example/opencensus/go.mod @@ -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 diff --git a/example/opencensus/main.go b/example/opencensus/main.go index 8014bb15d34..ceccb82d083 100644 --- a/example/opencensus/main.go +++ b/example/opencensus/main.go @@ -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" ) @@ -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) diff --git a/example/prometheus/go.mod b/example/prometheus/go.mod index 81c01ae990b..62bb10691ee 100644 --- a/example/prometheus/go.mod +++ b/example/prometheus/go.mod @@ -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 ) diff --git a/example/prometheus/main.go b/example/prometheus/main.go index 968beb3d483..4ef0f2e89e2 100644 --- a/example/prometheus/main.go +++ b/example/prometheus/main.go @@ -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" ) diff --git a/exporters/otlp/otlpmetric/exporter.go b/exporters/otlp/otlpmetric/exporter.go index 798b690be01..d6c9a6f4e76 100644 --- a/exporters/otlp/otlpmetric/exporter.go +++ b/exporters/otlp/otlpmetric/exporter.go @@ -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" ) @@ -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 @@ -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) { diff --git a/exporters/otlp/otlpmetric/exporter_test.go b/exporters/otlp/otlpmetric/exporter_test.go index 733d1978826..229d8838e27 100644 --- a/exporters/otlp/otlpmetric/exporter_test.go +++ b/exporters/otlp/otlpmetric/exporter_test.go @@ -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" @@ -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] @@ -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))) @@ -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, diff --git a/exporters/otlp/otlpmetric/go.mod b/exporters/otlp/otlpmetric/go.mod index fd520446cd3..93d3ff6a2be 100644 --- a/exporters/otlp/otlpmetric/go.mod +++ b/exporters/otlp/otlpmetric/go.mod @@ -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 diff --git a/exporters/otlp/otlpmetric/internal/metrictransform/metric.go b/exporters/otlp/otlpmetric/internal/metrictransform/metric.go index ac3673d72ed..e1ba26dccd0 100644 --- a/exporters/otlp/otlpmetric/internal/metrictransform/metric.go +++ b/exporters/otlp/otlpmetric/internal/metrictransform/metric.go @@ -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" diff --git a/exporters/otlp/otlpmetric/internal/metrictransform/metric_test.go b/exporters/otlp/otlpmetric/internal/metrictransform/metric_test.go index 3dd6c1db8fa..e103c3e9c53 100644 --- a/exporters/otlp/otlpmetric/internal/metrictransform/metric_test.go +++ b/exporters/otlp/otlpmetric/internal/metrictransform/metric_test.go @@ -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" ) diff --git a/exporters/otlp/otlpmetric/internal/otlpmetrictest/data.go b/exporters/otlp/otlpmetric/internal/otlpmetrictest/data.go index 65f79594ee6..cc3f7871598 100644 --- a/exporters/otlp/otlpmetric/internal/otlpmetrictest/data.go +++ b/exporters/otlp/otlpmetric/internal/otlpmetrictest/data.go @@ -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, @@ -45,17 +45,17 @@ 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) } @@ -63,9 +63,9 @@ func EmptyReader() exportmetric.InstrumentationLibraryReader { // 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") } diff --git a/exporters/otlp/otlpmetric/internal/otlpmetrictest/otlptest.go b/exporters/otlp/otlpmetric/internal/otlpmetrictest/otlptest.go index e14d548e84d..53af9d5565a 100644 --- a/exporters/otlp/otlpmetric/internal/otlpmetrictest/otlptest.go +++ b/exporters/otlp/otlpmetric/internal/otlpmetrictest/otlptest.go @@ -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" diff --git a/exporters/otlp/otlpmetric/options.go b/exporters/otlp/otlpmetric/options.go index dab33127be6..ce8a5f58c5a 100644 --- a/exporters/otlp/otlpmetric/options.go +++ b/exporters/otlp/otlpmetric/options.go @@ -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 { diff --git a/exporters/prometheus/go.mod b/exporters/prometheus/go.mod index 0875adce2eb..0546ae8466b 100644 --- a/exporters/prometheus/go.mod +++ b/exporters/prometheus/go.mod @@ -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 ) diff --git a/exporters/prometheus/prometheus.go b/exporters/prometheus/prometheus.go index 369c0ce1fe1..08595526263 100644 --- a/exporters/prometheus/prometheus.go +++ b/exporters/prometheus/prometheus.go @@ -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" ) diff --git a/exporters/prometheus/prometheus_test.go b/exporters/prometheus/prometheus_test.go index 5efdba33469..907db0db4b7 100644 --- a/exporters/prometheus/prometheus_test.go +++ b/exporters/prometheus/prometheus_test.go @@ -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" diff --git a/exporters/stdout/stdoutmetric/exporter.go b/exporters/stdout/stdoutmetric/exporter.go index 25b129dcdfd..e1ea02339c0 100644 --- a/exporters/stdout/stdoutmetric/exporter.go +++ b/exporters/stdout/stdoutmetric/exporter.go @@ -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. diff --git a/exporters/stdout/stdoutmetric/go.mod b/exporters/stdout/stdoutmetric/go.mod index 8347a15084c..c438a6f0037 100644 --- a/exporters/stdout/stdoutmetric/go.mod +++ b/exporters/stdout/stdoutmetric/go.mod @@ -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 ) diff --git a/exporters/stdout/stdoutmetric/metric.go b/exporters/stdout/stdoutmetric/metric.go index 4dde782da66..56e449de20d 100644 --- a/exporters/stdout/stdoutmetric/metric.go +++ b/exporters/stdout/stdoutmetric/metric.go @@ -23,9 +23,9 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric/sdkapi" - 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/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" "go.opentelemetry.io/otel/sdk/resource" ) @@ -33,7 +33,7 @@ type metricExporter struct { config config } -var _ exportmetric.Exporter = &metricExporter{} +var _ export.Exporter = &metricExporter{} type line struct { Name string `json:"Name"` @@ -49,10 +49,10 @@ func (e *metricExporter) TemporalityFor(desc *sdkapi.Descriptor, kind aggregatio return aggregation.StatelessTemporalitySelector().TemporalityFor(desc, kind) } -func (e *metricExporter) Export(_ context.Context, res *resource.Resource, reader exportmetric.InstrumentationLibraryReader) error { +func (e *metricExporter) Export(_ context.Context, res *resource.Resource, reader export.InstrumentationLibraryReader) error { var aggError error var batch []line - aggError = reader.ForEach(func(lib instrumentation.Library, mr exportmetric.Reader) error { + aggError = reader.ForEach(func(lib instrumentation.Library, mr export.Reader) error { var instLabels []attribute.KeyValue if name := lib.Name; name != "" { @@ -67,7 +67,7 @@ func (e *metricExporter) Export(_ context.Context, res *resource.Resource, reade instSet := attribute.NewSet(instLabels...) encodedInstLabels := instSet.Encoded(e.config.LabelEncoder) - return mr.ForEach(e, func(record exportmetric.Record) error { + return mr.ForEach(e, func(record export.Record) error { desc := record.Descriptor() agg := record.Aggregation() kind := desc.NumberKind() diff --git a/exporters/stdout/stdoutmetric/metric_test.go b/exporters/stdout/stdoutmetric/metric_test.go index 2106e65501c..e9153fcfd0a 100644 --- a/exporters/stdout/stdoutmetric/metric_test.go +++ b/exporters/stdout/stdoutmetric/metric_test.go @@ -29,8 +29,8 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/exporters/stdout/stdoutmetric" "go.opentelemetry.io/otel/metric" - "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/processor/processortest" "go.opentelemetry.io/otel/sdk/resource" diff --git a/sdk/export/metric/aggregation/aggregation.go b/sdk/export/metric/aggregation/aggregation.go index 800ec88fdbc..75617a237f7 100644 --- a/sdk/export/metric/aggregation/aggregation.go +++ b/sdk/export/metric/aggregation/aggregation.go @@ -15,117 +15,56 @@ package aggregation // import "go.opentelemetry.io/otel/sdk/export/metric/aggregation" import ( - "fmt" - "time" - - "go.opentelemetry.io/otel/metric/number" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" ) -// These interfaces describe the various ways to access state from an -// Aggregation. - -type ( - // Aggregation is an interface returned by the Aggregator - // containing an interval of metric data. - Aggregation interface { - // Kind returns a short identifying string to identify - // the Aggregator that was used to produce the - // Aggregation (e.g., "Sum"). - Kind() Kind - } +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" +type Aggregation = aggregation.Aggregation - // Sum returns an aggregated sum. - Sum interface { - Aggregation - Sum() (number.Number, error) - } +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" +type Sum = aggregation.Sum - // Count returns the number of values that were aggregated. - Count interface { - Aggregation - Count() (uint64, error) - } +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" +type Count = aggregation.Count - // Min returns the minimum value over the set of values that were aggregated. - Min interface { - Aggregation - Min() (number.Number, error) - } +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" +type Min = aggregation.Min - // Max returns the maximum value over the set of values that were aggregated. - Max interface { - Aggregation - Max() (number.Number, error) - } +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" +type Max = aggregation.Max - // LastValue returns the latest value that was aggregated. - LastValue interface { - Aggregation - LastValue() (number.Number, time.Time, error) - } +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" +type LastValue = aggregation.LastValue - // Buckets represents histogram buckets boundaries and counts. - // - // For a Histogram with N defined boundaries, e.g, [x, y, z]. - // There are N+1 counts: [-inf, x), [x, y), [y, z), [z, +inf] - Buckets struct { - // Boundaries are floating point numbers, even when - // aggregating integers. - Boundaries []float64 +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" +type Buckets = aggregation.Buckets - // Counts holds the count in each bucket. - Counts []uint64 - } - - // Histogram returns the count of events in pre-determined buckets. - Histogram interface { - Aggregation - Count() (uint64, error) - Sum() (number.Number, error) - Histogram() (Buckets, error) - } -) +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" +type Histogram = aggregation.Histogram -type ( - // Kind is a short name for the Aggregator that produces an - // Aggregation, used for descriptive purpose only. Kind is a - // string to allow user-defined Aggregators. - // - // When deciding how to handle an Aggregation, Exporters are - // encouraged to decide based on conversion to the above - // interfaces based on strength, not on Kind value, when - // deciding how to expose metric data. This enables - // user-supplied Aggregators to replace builtin Aggregators. - // - // For example, test for a Histogram before testing for a - // Sum, and so on. - Kind string -) +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" +type Kind = aggregation.Kind -// Kind description constants. const ( - SumKind Kind = "Sum" - HistogramKind Kind = "Histogram" - LastValueKind Kind = "Lastvalue" + // Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" + SumKind = aggregation.SumKind + // Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" + HistogramKind = aggregation.HistogramKind + // Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" + LastValueKind = aggregation.LastValueKind ) -// Sentinel errors for Aggregation interface. var ( - ErrNegativeInput = fmt.Errorf("negative value is out of range for this instrument") - ErrNaNInput = fmt.Errorf("NaN value is an invalid input") - ErrInconsistentType = fmt.Errorf("inconsistent aggregator types") - - // ErrNoCumulativeToDelta is returned when requesting delta - // export kind for a precomputed sum instrument. - ErrNoCumulativeToDelta = fmt.Errorf("cumulative to delta not implemented") - - // ErrNoData is returned when (due to a race with collection) - // the Aggregator is check-pointed before the first value is set. - // The aggregator should simply be skipped in this case. - ErrNoData = fmt.Errorf("no data collected by this aggregator") + // Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" + ErrNegativeInput = aggregation.ErrNegativeInput + // Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" + ErrNaNInput = aggregation.ErrNaNInput + // Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" + ErrInconsistentType = aggregation.ErrInconsistentType + + // Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" + ErrNoCumulativeToDelta = aggregation.ErrNoCumulativeToDelta + + // Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" + ErrNoData = aggregation.ErrNoData ) - -// String returns the string value of Kind. -func (k Kind) String() string { - return string(k) -} diff --git a/sdk/export/metric/aggregation/temporality.go b/sdk/export/metric/aggregation/temporality.go index 4a4a733aa28..b791ea4b3d6 100644 --- a/sdk/export/metric/aggregation/temporality.go +++ b/sdk/export/metric/aggregation/temporality.go @@ -17,101 +17,39 @@ package aggregation // import "go.opentelemetry.io/otel/sdk/export/metric/aggregation" import ( - "go.opentelemetry.io/otel/metric/sdkapi" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" ) -// Temporality indicates the temporal aggregation exported by an exporter. -// These bits may be OR-d together when multiple exporters are in use. -type Temporality uint8 +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" +type Temporality = aggregation.Temporality const ( - // CumulativeTemporality indicates that an Exporter expects a - // Cumulative Aggregation. - CumulativeTemporality Temporality = 1 + // Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" + CumulativeTemporality = aggregation.CumulativeTemporality - // DeltaTemporality indicates that an Exporter expects a - // Delta Aggregation. - DeltaTemporality Temporality = 2 + // Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" + DeltaTemporality = aggregation.DeltaTemporality ) -// Includes returns if t includes support for other temporality. -func (t Temporality) Includes(other Temporality) bool { - return t&other != 0 -} - -// MemoryRequired returns whether an exporter of this temporality requires -// memory to export correctly. -func (t Temporality) MemoryRequired(mkind sdkapi.InstrumentKind) bool { - switch mkind { - case sdkapi.HistogramInstrumentKind, sdkapi.GaugeObserverInstrumentKind, - sdkapi.CounterInstrumentKind, sdkapi.UpDownCounterInstrumentKind: - // Delta-oriented instruments: - return t.Includes(CumulativeTemporality) - - case sdkapi.CounterObserverInstrumentKind, sdkapi.UpDownCounterObserverInstrumentKind: - // Cumulative-oriented instruments: - return t.Includes(DeltaTemporality) - } - // Something unexpected is happening--we could panic. This - // will become an error when the exporter tries to access a - // checkpoint, presumably, so let it be. - return false -} - -type ( - constantTemporalitySelector Temporality - statelessTemporalitySelector struct{} -) - -var ( - _ TemporalitySelector = constantTemporalitySelector(0) - _ TemporalitySelector = statelessTemporalitySelector{} -) - -// ConstantTemporalitySelector returns an TemporalitySelector that returns -// a constant Temporality. +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" func ConstantTemporalitySelector(t Temporality) TemporalitySelector { - return constantTemporalitySelector(t) + return aggregation.ConstantTemporalitySelector(t) } -// CumulativeTemporalitySelector returns an TemporalitySelector that -// always returns CumulativeTemporality. +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" func CumulativeTemporalitySelector() TemporalitySelector { - return ConstantTemporalitySelector(CumulativeTemporality) + return aggregation.CumulativeTemporalitySelector() } -// DeltaTemporalitySelector returns an TemporalitySelector that -// always returns DeltaTemporality. +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" func DeltaTemporalitySelector() TemporalitySelector { - return ConstantTemporalitySelector(DeltaTemporality) + return aggregation.DeltaTemporalitySelector() } -// StatelessTemporalitySelector returns an TemporalitySelector that -// always returns the Temporality that avoids long-term memory -// requirements. +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" func StatelessTemporalitySelector() TemporalitySelector { - return statelessTemporalitySelector{} -} - -// TemporalityFor implements TemporalitySelector. -func (c constantTemporalitySelector) TemporalityFor(_ *sdkapi.Descriptor, _ Kind) Temporality { - return Temporality(c) + return aggregation.StatelessTemporalitySelector() } -// TemporalityFor implements TemporalitySelector. -func (s statelessTemporalitySelector) TemporalityFor(desc *sdkapi.Descriptor, kind Kind) Temporality { - if kind == SumKind && desc.InstrumentKind().PrecomputedSum() { - return CumulativeTemporality - } - return DeltaTemporality -} - -// TemporalitySelector is a sub-interface of Exporter used to indicate -// whether the Processor should compute Delta or Cumulative -// Aggregations. -type TemporalitySelector interface { - // TemporalityFor should return the correct Temporality that - // should be used when exporting data for the given metric - // instrument and Aggregator kind. - TemporalityFor(descriptor *sdkapi.Descriptor, aggregationKind Kind) Temporality -} +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export/aggregation" +type TemporalitySelector = aggregation.TemporalitySelector diff --git a/sdk/export/metric/go.mod b/sdk/export/metric/go.mod index 09404489a42..2b10328d6a7 100644 --- a/sdk/export/metric/go.mod +++ b/sdk/export/metric/go.mod @@ -1,3 +1,4 @@ +// Deprecated: use go.opentelemetry.io/otel/sdk/metric instead. module go.opentelemetry.io/otel/sdk/export/metric go 1.16 @@ -41,10 +42,9 @@ replace go.opentelemetry.io/otel/sdk/metric => ../../metric replace go.opentelemetry.io/otel/trace => ../../../trace require ( - github.com/stretchr/testify v1.7.0 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/metric v0.0.0-00010101000000-000000000000 ) replace go.opentelemetry.io/otel/example/passthrough => ../../../example/passthrough diff --git a/sdk/export/metric/go.sum b/sdk/export/metric/go.sum index 7c328dde18e..a5e093f7231 100644 --- a/sdk/export/metric/go.sum +++ b/sdk/export/metric/go.sum @@ -1,3 +1,4 @@ +github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -15,7 +16,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/export/metric/metric.go b/sdk/export/metric/metric.go index 81e579b8bab..5da6b3f061f 100644 --- a/sdk/export/metric/metric.go +++ b/sdk/export/metric/metric.go @@ -15,329 +15,53 @@ package metric // import "go.opentelemetry.io/otel/sdk/export/metric" import ( - "context" - "sync" "time" "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/metric/number" "go.opentelemetry.io/otel/metric/sdkapi" - "go.opentelemetry.io/otel/sdk/export/metric/aggregation" - "go.opentelemetry.io/otel/sdk/instrumentation" - "go.opentelemetry.io/otel/sdk/resource" + "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" ) -// Processor is responsible for deciding which kind of aggregation to -// use (via AggregatorSelector), gathering exported results from the -// SDK during collection, and deciding over which dimensions to group -// the exported data. -// -// The SDK supports binding only one of these interfaces, as it has -// the sole responsibility of determining which Aggregator to use for -// each record. -// -// The embedded AggregatorSelector interface is called (concurrently) -// in instrumentation context to select the appropriate Aggregator for -// an instrument. -// -// The `Process` method is called during collection in a -// single-threaded context from the SDK, after the aggregator is -// checkpointed, allowing the processor to build the set of metrics -// currently being exported. -type Processor interface { - // AggregatorSelector is responsible for selecting the - // concrete type of Aggregator used for a metric in the SDK. - // - // This may be a static decision based on fields of the - // Descriptor, or it could use an external configuration - // source to customize the treatment of each metric - // instrument. - // - // The result from AggregatorSelector.AggregatorFor should be - // the same type for a given Descriptor or else nil. The same - // type should be returned for a given descriptor, because - // Aggregators only know how to Merge with their own type. If - // the result is nil, the metric instrument will be disabled. - // - // Note that the SDK only calls AggregatorFor when new records - // require an Aggregator. This does not provide a way to - // disable metrics with active records. - AggregatorSelector - - // Process is called by the SDK once per internal record, - // passing the export Accumulation (a Descriptor, the corresponding - // Labels, and the checkpointed Aggregator). This call has no - // Context argument because it is expected to perform only - // computation. An SDK is not expected to call exporters from - // with Process, use a controller for that (see - // ./controllers/{pull,push}. - Process(accum Accumulation) error -} +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export" +type Accumulation = export.Accumulation -// AggregatorSelector supports selecting the kind of Aggregator to -// use at runtime for a specific metric instrument. -type AggregatorSelector interface { - // AggregatorFor allocates a variable number of aggregators of - // a kind suitable for the requested export. This method - // initializes a `...*Aggregator`, to support making a single - // allocation. - // - // When the call returns without initializing the *Aggregator - // to a non-nil value, the metric instrument is explicitly - // disabled. - // - // This must return a consistent type to avoid confusion in - // later stages of the metrics export process, i.e., when - // Merging or Checkpointing aggregators for a specific - // instrument. - // - // Note: This is context-free because the aggregator should - // not relate to the incoming context. This call should not - // block. - AggregatorFor(descriptor *sdkapi.Descriptor, aggregator ...*Aggregator) -} +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export" +type Aggregator = export.Aggregator -// Checkpointer is the interface used by a Controller to coordinate -// the Processor with Accumulator(s) and Exporter(s). The -// StartCollection() and FinishCollection() methods start and finish a -// collection interval. Controllers call the Accumulator(s) during -// collection to process Accumulations. -type Checkpointer interface { - // Processor processes metric data for export. The Process - // method is bracketed by StartCollection and FinishCollection - // calls. The embedded AggregatorSelector can be called at - // any time. - Processor +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export" +type AggregatorSelector = export.AggregatorSelector - // Reader returns the current data set. This may be - // called before and after collection. The - // implementation is required to return the same value - // throughout its lifetime, since Reader exposes a - // sync.Locker interface. The caller is responsible for - // locking the Reader before initiating collection. - Reader() Reader +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export" +type Checkpointer = export.Checkpointer - // StartCollection begins a collection interval. - StartCollection() +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export" +type CheckpointerFactory = export.CheckpointerFactory - // FinishCollection ends a collection interval. - FinishCollection() error -} +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export" +type Exporter = export.Exporter -// CheckpointerFactory is an interface for producing configured -// Checkpointer instances. -type CheckpointerFactory interface { - NewCheckpointer() Checkpointer -} +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export" +type InstrumentationLibraryReader = export.Exporter -// Aggregator implements a specific aggregation behavior, e.g., a -// behavior to track a sequence of updates to an instrument. Counter -// instruments commonly use a simple Sum aggregator, but for the -// distribution instruments (Histogram, GaugeObserver) there are a -// number of possible aggregators with different cost and accuracy -// tradeoffs. -// -// Note that any Aggregator may be attached to any instrument--this is -// the result of the OpenTelemetry API/SDK separation. It is possible -// to attach a Sum aggregator to a Histogram instrument. -type Aggregator interface { - // Aggregation returns an Aggregation interface to access the - // current state of this Aggregator. The caller is - // responsible for synchronization and must not call any the - // other methods in this interface concurrently while using - // the Aggregation. - Aggregation() aggregation.Aggregation +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export" +type Metadata = export.Metadata - // Update receives a new measured value and incorporates it - // into the aggregation. Update() calls may be called - // concurrently. - // - // Descriptor.NumberKind() should be consulted to determine - // whether the provided number is an int64 or float64. - // - // The Context argument comes from user-level code and could be - // inspected for a `correlation.Map` or `trace.SpanContext`. - Update(ctx context.Context, number number.Number, descriptor *sdkapi.Descriptor) error +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export" +type Processor = export.Processor - // SynchronizedMove is called during collection to finish one - // period of aggregation by atomically saving the - // currently-updating state into the argument Aggregator AND - // resetting the current value to the zero state. - // - // SynchronizedMove() is called concurrently with Update(). These - // two methods must be synchronized with respect to each - // other, for correctness. - // - // After saving a synchronized copy, the Aggregator can be converted - // into one or more of the interfaces in the `aggregation` sub-package, - // according to kind of Aggregator that was selected. - // - // This method will return an InconsistentAggregatorError if - // this Aggregator cannot be copied into the destination due - // to an incompatible type. - // - // This call has no Context argument because it is expected to - // perform only computation. - // - // When called with a nil `destination`, this Aggregator is reset - // and the current value is discarded. - SynchronizedMove(destination Aggregator, descriptor *sdkapi.Descriptor) error +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export" +type Reader = export.Reader - // Merge combines the checkpointed state from the argument - // Aggregator into this Aggregator. Merge is not synchronized - // with respect to Update or SynchronizedMove. - // - // The owner of an Aggregator being merged is responsible for - // synchronization of both Aggregator states. - Merge(aggregator Aggregator, descriptor *sdkapi.Descriptor) error -} - -// Exporter handles presentation of the checkpoint of aggregate -// metrics. This is the final stage of a metrics export pipeline, -// where metric data are formatted for a specific system. -type Exporter interface { - // Export is called immediately after completing a collection - // pass in the SDK. - // - // The Context comes from the controller that initiated - // collection. - // - // The InstrumentationLibraryReader interface refers to the - // Processor that just completed collection. - Export(ctx context.Context, resource *resource.Resource, reader InstrumentationLibraryReader) error - - // TemporalitySelector is an interface used by the Processor - // in deciding whether to compute Delta or Cumulative - // Aggregations when passing Records to this Exporter. - aggregation.TemporalitySelector -} - -// InstrumentationLibraryReader is an interface for exporters to iterate -// over one instrumentation library of metric data at a time. -type InstrumentationLibraryReader interface { - // ForEach calls the passed function once per instrumentation library, - // allowing the caller to emit metrics grouped by the library that - // produced them. - ForEach(readerFunc func(instrumentation.Library, Reader) error) error -} - -// Reader allows a controller to access a complete checkpoint of -// aggregated metrics from the Processor for a single library of -// metric data. This is passed to the Exporter which may then use -// ForEach to iterate over the collection of aggregated metrics. -type Reader interface { - // ForEach iterates over aggregated checkpoints for all - // metrics that were updated during the last collection - // period. Each aggregated checkpoint returned by the - // function parameter may return an error. - // - // The TemporalitySelector argument is used to determine - // whether the Record is computed using Delta or Cumulative - // aggregation. - // - // ForEach tolerates ErrNoData silently, as this is - // expected from the Meter implementation. Any other kind - // of error will immediately halt ForEach and return - // the error to the caller. - ForEach(tempSelector aggregation.TemporalitySelector, recordFunc func(Record) error) error - - // Locker supports locking the checkpoint set. Collection - // into the checkpoint set cannot take place (in case of a - // stateful processor) while it is locked. - // - // The Processor attached to the Accumulator MUST be called - // with the lock held. - sync.Locker - - // RLock acquires a read lock corresponding to this Locker. - RLock() - // RUnlock releases a read lock corresponding to this Locker. - RUnlock() -} +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export" +type Record = export.Record -// Metadata contains the common elements for exported metric data that -// are shared by the Accumulator->Processor and Processor->Exporter -// steps. -type Metadata struct { - descriptor *sdkapi.Descriptor - labels *attribute.Set -} - -// Accumulation contains the exported data for a single metric instrument -// and label set, as prepared by an Accumulator for the Processor. -type Accumulation struct { - Metadata - aggregator Aggregator -} - -// Record contains the exported data for a single metric instrument -// and label set, as prepared by the Processor for the Exporter. -// This includes the effective start and end time for the aggregation. -type Record struct { - Metadata - aggregation aggregation.Aggregation - start time.Time - end time.Time -} - -// Descriptor describes the metric instrument being exported. -func (m Metadata) Descriptor() *sdkapi.Descriptor { - return m.descriptor -} - -// Labels describes the labels associated with the instrument and the -// aggregated data. -func (m Metadata) Labels() *attribute.Set { - return m.labels -} - -// NewAccumulation allows Accumulator implementations to construct new -// Accumulations to send to Processors. The Descriptor, Labels, -// and Aggregator represent aggregate metric events received over a single -// collection period. +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export" func NewAccumulation(descriptor *sdkapi.Descriptor, labels *attribute.Set, aggregator Aggregator) Accumulation { - return Accumulation{ - Metadata: Metadata{ - descriptor: descriptor, - labels: labels, - }, - aggregator: aggregator, - } -} - -// Aggregator returns the checkpointed aggregator. It is safe to -// access the checkpointed state without locking. -func (r Accumulation) Aggregator() Aggregator { - return r.aggregator + return export.NewAccumulation(descriptor, labels, aggregator) } -// NewRecord allows Processor implementations to construct export -// records. The Descriptor, Labels, and Aggregator represent -// aggregate metric events received over a single collection period. +// Deprecated: use module "go.opentelemetry.io/otel/sdk/metric/export" func NewRecord(descriptor *sdkapi.Descriptor, labels *attribute.Set, aggregation aggregation.Aggregation, start, end time.Time) Record { - return Record{ - Metadata: Metadata{ - descriptor: descriptor, - labels: labels, - }, - aggregation: aggregation, - start: start, - end: end, - } -} - -// Aggregation returns the aggregation, an interface to the record and -// its aggregator, dependent on the kind of both the input and exporter. -func (r Record) Aggregation() aggregation.Aggregation { - return r.aggregation -} - -// StartTime is the start time of the interval covered by this aggregation. -func (r Record) StartTime() time.Time { - return r.start -} - -// EndTime is the end time of the interval covered by this aggregation. -func (r Record) EndTime() time.Time { - return r.end + return export.NewRecord(descriptor, labels, aggregation, start, end) } diff --git a/sdk/metric/aggregator/aggregator.go b/sdk/metric/aggregator/aggregator.go index 13a315e2d4a..103c08cfa0b 100644 --- a/sdk/metric/aggregator/aggregator.go +++ b/sdk/metric/aggregator/aggregator.go @@ -20,8 +20,8 @@ import ( "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/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" ) // NewInconsistentAggregatorError formats an error describing an attempt to diff --git a/sdk/metric/aggregator/aggregator_test.go b/sdk/metric/aggregator/aggregator_test.go index fd85297ed1d..bf405b5c3f8 100644 --- a/sdk/metric/aggregator/aggregator_test.go +++ b/sdk/metric/aggregator/aggregator_test.go @@ -24,10 +24,10 @@ import ( "go.opentelemetry.io/otel/metric/metrictest" "go.opentelemetry.io/otel/metric/number" "go.opentelemetry.io/otel/metric/sdkapi" - "go.opentelemetry.io/otel/sdk/export/metric/aggregation" "go.opentelemetry.io/otel/sdk/metric/aggregator" "go.opentelemetry.io/otel/sdk/metric/aggregator/lastvalue" "go.opentelemetry.io/otel/sdk/metric/aggregator/sum" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" ) func TestInconsistentAggregatorErr(t *testing.T) { diff --git a/sdk/metric/aggregator/aggregatortest/test.go b/sdk/metric/aggregator/aggregatortest/test.go index 2fbfca5eed9..48b92ec9c7e 100644 --- a/sdk/metric/aggregator/aggregatortest/test.go +++ b/sdk/metric/aggregator/aggregatortest/test.go @@ -29,9 +29,9 @@ 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" + "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" ) const Magnitude = 1000 diff --git a/sdk/metric/aggregator/histogram/histogram.go b/sdk/metric/aggregator/histogram/histogram.go index 899c71cacd1..888c985ce3e 100644 --- a/sdk/metric/aggregator/histogram/histogram.go +++ b/sdk/metric/aggregator/histogram/histogram.go @@ -21,9 +21,9 @@ import ( "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" + "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" ) // Note: This code uses a Mutex to govern access to the exclusive diff --git a/sdk/metric/aggregator/histogram/histogram_test.go b/sdk/metric/aggregator/histogram/histogram_test.go index a4c5c6da687..2d09edbfdc9 100644 --- a/sdk/metric/aggregator/histogram/histogram_test.go +++ b/sdk/metric/aggregator/histogram/histogram_test.go @@ -25,9 +25,9 @@ import ( "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/metric/aggregator/aggregatortest" "go.opentelemetry.io/otel/sdk/metric/aggregator/histogram" + "go.opentelemetry.io/otel/sdk/metric/export" ) const count = 100 diff --git a/sdk/metric/aggregator/lastvalue/lastvalue.go b/sdk/metric/aggregator/lastvalue/lastvalue.go index 71b117890cb..4a1da706062 100644 --- a/sdk/metric/aggregator/lastvalue/lastvalue.go +++ b/sdk/metric/aggregator/lastvalue/lastvalue.go @@ -22,9 +22,9 @@ import ( "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" + "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" ) type ( diff --git a/sdk/metric/aggregator/lastvalue/lastvalue_test.go b/sdk/metric/aggregator/lastvalue/lastvalue_test.go index 8f1a771009c..bdfe6a65bd4 100644 --- a/sdk/metric/aggregator/lastvalue/lastvalue_test.go +++ b/sdk/metric/aggregator/lastvalue/lastvalue_test.go @@ -27,9 +27,9 @@ import ( ottest "go.opentelemetry.io/otel/internal/internaltest" "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/aggregatortest" + "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" ) const count = 100 diff --git a/sdk/metric/aggregator/sum/sum.go b/sdk/metric/aggregator/sum/sum.go index 8c1d11c715d..d048e9bc253 100644 --- a/sdk/metric/aggregator/sum/sum.go +++ b/sdk/metric/aggregator/sum/sum.go @@ -19,9 +19,9 @@ import ( "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" + "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" ) // Aggregator aggregates counter events. diff --git a/sdk/metric/aggregator/sum/sum_test.go b/sdk/metric/aggregator/sum/sum_test.go index 3387c83cc8d..da614d83f49 100644 --- a/sdk/metric/aggregator/sum/sum_test.go +++ b/sdk/metric/aggregator/sum/sum_test.go @@ -24,8 +24,8 @@ import ( ottest "go.opentelemetry.io/otel/internal/internaltest" "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/metric/aggregator/aggregatortest" + "go.opentelemetry.io/otel/sdk/metric/export" ) const count = 100 diff --git a/sdk/metric/benchmark_test.go b/sdk/metric/benchmark_test.go index 585bf43609c..eb89f54b330 100644 --- a/sdk/metric/benchmark_test.go +++ b/sdk/metric/benchmark_test.go @@ -24,8 +24,8 @@ import ( "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/global" "go.opentelemetry.io/otel/metric/sdkapi" - export "go.opentelemetry.io/otel/sdk/export/metric" sdk "go.opentelemetry.io/otel/sdk/metric" + "go.opentelemetry.io/otel/sdk/metric/export" "go.opentelemetry.io/otel/sdk/metric/processor/processortest" ) diff --git a/sdk/metric/controller/basic/config.go b/sdk/metric/controller/basic/config.go index cbc91a8f59d..01691ecadd1 100644 --- a/sdk/metric/controller/basic/config.go +++ b/sdk/metric/controller/basic/config.go @@ -18,7 +18,7 @@ import ( "time" "go.opentelemetry.io/otel" - export "go.opentelemetry.io/otel/sdk/export/metric" + "go.opentelemetry.io/otel/sdk/metric/export" "go.opentelemetry.io/otel/sdk/resource" ) diff --git a/sdk/metric/controller/basic/controller.go b/sdk/metric/controller/basic/controller.go index bf3be5fe1c9..a684f65678e 100644 --- a/sdk/metric/controller/basic/controller.go +++ b/sdk/metric/controller/basic/controller.go @@ -23,10 +23,10 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/internal/metric/registry" "go.opentelemetry.io/otel/metric" - export "go.opentelemetry.io/otel/sdk/export/metric" "go.opentelemetry.io/otel/sdk/instrumentation" sdk "go.opentelemetry.io/otel/sdk/metric" controllerTime "go.opentelemetry.io/otel/sdk/metric/controller/time" + "go.opentelemetry.io/otel/sdk/metric/export" "go.opentelemetry.io/otel/sdk/resource" ) diff --git a/sdk/metric/controller/basic/controller_test.go b/sdk/metric/controller/basic/controller_test.go index 870e65f2c0c..503a278148c 100644 --- a/sdk/metric/controller/basic/controller_test.go +++ b/sdk/metric/controller/basic/controller_test.go @@ -27,11 +27,11 @@ import ( ottest "go.opentelemetry.io/otel/internal/internaltest" "go.opentelemetry.io/otel/metric" "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/controller/controllertest" + "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/processor/processortest" "go.opentelemetry.io/otel/sdk/resource" diff --git a/sdk/metric/controller/basic/pull_test.go b/sdk/metric/controller/basic/pull_test.go index 6e87c6f6a97..96d1e1adad1 100644 --- a/sdk/metric/controller/basic/pull_test.go +++ b/sdk/metric/controller/basic/pull_test.go @@ -24,9 +24,9 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/sdk/export/metric/aggregation" controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" "go.opentelemetry.io/otel/sdk/metric/controller/controllertest" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/processor/processortest" "go.opentelemetry.io/otel/sdk/resource" diff --git a/sdk/metric/controller/basic/push_test.go b/sdk/metric/controller/basic/push_test.go index 775754774bf..0a6679b29de 100644 --- a/sdk/metric/controller/basic/push_test.go +++ b/sdk/metric/controller/basic/push_test.go @@ -28,10 +28,10 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" - export "go.opentelemetry.io/otel/sdk/export/metric" - "go.opentelemetry.io/otel/sdk/export/metric/aggregation" controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" "go.opentelemetry.io/otel/sdk/metric/controller/controllertest" + "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/processor/processortest" "go.opentelemetry.io/otel/sdk/resource" diff --git a/sdk/metric/controller/controllertest/test.go b/sdk/metric/controller/controllertest/test.go index 8676129ebe5..ed0bb88f1a3 100644 --- a/sdk/metric/controller/controllertest/test.go +++ b/sdk/metric/controller/controllertest/test.go @@ -19,10 +19,10 @@ import ( "github.com/benbjohnson/clock" - export "go.opentelemetry.io/otel/sdk/export/metric" - "go.opentelemetry.io/otel/sdk/export/metric/aggregation" "go.opentelemetry.io/otel/sdk/instrumentation" controllerTime "go.opentelemetry.io/otel/sdk/metric/controller/time" + "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" ) type MockClock struct { diff --git a/sdk/metric/correct_test.go b/sdk/metric/correct_test.go index 70eadfeca86..f5fd7ea814f 100644 --- a/sdk/metric/correct_test.go +++ b/sdk/metric/correct_test.go @@ -27,9 +27,9 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/sdkapi" - export "go.opentelemetry.io/otel/sdk/export/metric" - "go.opentelemetry.io/otel/sdk/export/metric/aggregation" metricsdk "go.opentelemetry.io/otel/sdk/metric" + "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" "go.opentelemetry.io/otel/sdk/metric/processor/processortest" ) diff --git a/sdk/metric/doc.go b/sdk/metric/doc.go index 752c3db85c0..e3270211be1 100644 --- a/sdk/metric/doc.go +++ b/sdk/metric/doc.go @@ -65,7 +65,7 @@ Export Pipeline While the SDK serves to maintain a current set of records and coordinate collection, the behavior of a metrics export pipeline is configured through the export types in -go.opentelemetry.io/otel/sdk/export/metric. It is important to keep +go.opentelemetry.io/otel/sdk/metric/export. It is important to keep in mind the context these interfaces are called from. There are two contexts, instrumentation context, where a user-level goroutine that enters the SDK resulting in a new record, and collection context, diff --git a/sdk/metric/export/aggregation/aggregation.go b/sdk/metric/export/aggregation/aggregation.go new file mode 100644 index 00000000000..4d5254ed71b --- /dev/null +++ b/sdk/metric/export/aggregation/aggregation.go @@ -0,0 +1,131 @@ +// 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 aggregation // import "go.opentelemetry.io/otel/sdk/metric/export/aggregation" + +import ( + "fmt" + "time" + + "go.opentelemetry.io/otel/metric/number" +) + +// These interfaces describe the various ways to access state from an +// Aggregation. + +type ( + // Aggregation is an interface returned by the Aggregator + // containing an interval of metric data. + Aggregation interface { + // Kind returns a short identifying string to identify + // the Aggregator that was used to produce the + // Aggregation (e.g., "Sum"). + Kind() Kind + } + + // Sum returns an aggregated sum. + Sum interface { + Aggregation + Sum() (number.Number, error) + } + + // Count returns the number of values that were aggregated. + Count interface { + Aggregation + Count() (uint64, error) + } + + // Min returns the minimum value over the set of values that were aggregated. + Min interface { + Aggregation + Min() (number.Number, error) + } + + // Max returns the maximum value over the set of values that were aggregated. + Max interface { + Aggregation + Max() (number.Number, error) + } + + // LastValue returns the latest value that was aggregated. + LastValue interface { + Aggregation + LastValue() (number.Number, time.Time, error) + } + + // Buckets represents histogram buckets boundaries and counts. + // + // For a Histogram with N defined boundaries, e.g, [x, y, z]. + // There are N+1 counts: [-inf, x), [x, y), [y, z), [z, +inf] + Buckets struct { + // Boundaries are floating point numbers, even when + // aggregating integers. + Boundaries []float64 + + // Counts holds the count in each bucket. + Counts []uint64 + } + + // Histogram returns the count of events in pre-determined buckets. + Histogram interface { + Aggregation + Count() (uint64, error) + Sum() (number.Number, error) + Histogram() (Buckets, error) + } +) + +type ( + // Kind is a short name for the Aggregator that produces an + // Aggregation, used for descriptive purpose only. Kind is a + // string to allow user-defined Aggregators. + // + // When deciding how to handle an Aggregation, Exporters are + // encouraged to decide based on conversion to the above + // interfaces based on strength, not on Kind value, when + // deciding how to expose metric data. This enables + // user-supplied Aggregators to replace builtin Aggregators. + // + // For example, test for a Histogram before testing for a + // Sum, and so on. + Kind string +) + +// Kind description constants. +const ( + SumKind Kind = "Sum" + HistogramKind Kind = "Histogram" + LastValueKind Kind = "Lastvalue" +) + +// Sentinel errors for Aggregation interface. +var ( + ErrNegativeInput = fmt.Errorf("negative value is out of range for this instrument") + ErrNaNInput = fmt.Errorf("NaN value is an invalid input") + ErrInconsistentType = fmt.Errorf("inconsistent aggregator types") + + // ErrNoCumulativeToDelta is returned when requesting delta + // export kind for a precomputed sum instrument. + ErrNoCumulativeToDelta = fmt.Errorf("cumulative to delta not implemented") + + // ErrNoData is returned when (due to a race with collection) + // the Aggregator is check-pointed before the first value is set. + // The aggregator should simply be skipped in this case. + ErrNoData = fmt.Errorf("no data collected by this aggregator") +) + +// String returns the string value of Kind. +func (k Kind) String() string { + return string(k) +} diff --git a/sdk/metric/export/aggregation/temporality.go b/sdk/metric/export/aggregation/temporality.go new file mode 100644 index 00000000000..ca71b79d03f --- /dev/null +++ b/sdk/metric/export/aggregation/temporality.go @@ -0,0 +1,117 @@ +// 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. + +//go:generate stringer -type=Temporality + +package aggregation // import "go.opentelemetry.io/otel/sdk/metric/export/aggregation" + +import ( + "go.opentelemetry.io/otel/metric/sdkapi" +) + +// Temporality indicates the temporal aggregation exported by an exporter. +// These bits may be OR-d together when multiple exporters are in use. +type Temporality uint8 + +const ( + // CumulativeTemporality indicates that an Exporter expects a + // Cumulative Aggregation. + CumulativeTemporality Temporality = 1 + + // DeltaTemporality indicates that an Exporter expects a + // Delta Aggregation. + DeltaTemporality Temporality = 2 +) + +// Includes returns if t includes support for other temporality. +func (t Temporality) Includes(other Temporality) bool { + return t&other != 0 +} + +// MemoryRequired returns whether an exporter of this temporality requires +// memory to export correctly. +func (t Temporality) MemoryRequired(mkind sdkapi.InstrumentKind) bool { + switch mkind { + case sdkapi.HistogramInstrumentKind, sdkapi.GaugeObserverInstrumentKind, + sdkapi.CounterInstrumentKind, sdkapi.UpDownCounterInstrumentKind: + // Delta-oriented instruments: + return t.Includes(CumulativeTemporality) + + case sdkapi.CounterObserverInstrumentKind, sdkapi.UpDownCounterObserverInstrumentKind: + // Cumulative-oriented instruments: + return t.Includes(DeltaTemporality) + } + // Something unexpected is happening--we could panic. This + // will become an error when the exporter tries to access a + // checkpoint, presumably, so let it be. + return false +} + +type ( + constantTemporalitySelector Temporality + statelessTemporalitySelector struct{} +) + +var ( + _ TemporalitySelector = constantTemporalitySelector(0) + _ TemporalitySelector = statelessTemporalitySelector{} +) + +// ConstantTemporalitySelector returns an TemporalitySelector that returns +// a constant Temporality. +func ConstantTemporalitySelector(t Temporality) TemporalitySelector { + return constantTemporalitySelector(t) +} + +// CumulativeTemporalitySelector returns an TemporalitySelector that +// always returns CumulativeTemporality. +func CumulativeTemporalitySelector() TemporalitySelector { + return ConstantTemporalitySelector(CumulativeTemporality) +} + +// DeltaTemporalitySelector returns an TemporalitySelector that +// always returns DeltaTemporality. +func DeltaTemporalitySelector() TemporalitySelector { + return ConstantTemporalitySelector(DeltaTemporality) +} + +// StatelessTemporalitySelector returns an TemporalitySelector that +// always returns the Temporality that avoids long-term memory +// requirements. +func StatelessTemporalitySelector() TemporalitySelector { + return statelessTemporalitySelector{} +} + +// TemporalityFor implements TemporalitySelector. +func (c constantTemporalitySelector) TemporalityFor(_ *sdkapi.Descriptor, _ Kind) Temporality { + return Temporality(c) +} + +// TemporalityFor implements TemporalitySelector. +func (s statelessTemporalitySelector) TemporalityFor(desc *sdkapi.Descriptor, kind Kind) Temporality { + if kind == SumKind && desc.InstrumentKind().PrecomputedSum() { + return CumulativeTemporality + } + return DeltaTemporality +} + +// TemporalitySelector is a sub-interface of Exporter used to indicate +// whether the Processor should compute Delta or Cumulative +// Aggregations. +type TemporalitySelector interface { + // TemporalityFor should return the correct Temporality that + // should be used when exporting data for the given metric + // instrument and Aggregator kind. + TemporalityFor(descriptor *sdkapi.Descriptor, aggregationKind Kind) Temporality +} diff --git a/sdk/export/metric/aggregation/temporality_string.go b/sdk/metric/export/aggregation/temporality_string.go similarity index 100% rename from sdk/export/metric/aggregation/temporality_string.go rename to sdk/metric/export/aggregation/temporality_string.go diff --git a/sdk/export/metric/aggregation/temporality_test.go b/sdk/metric/export/aggregation/temporality_test.go similarity index 100% rename from sdk/export/metric/aggregation/temporality_test.go rename to sdk/metric/export/aggregation/temporality_test.go diff --git a/sdk/metric/export/metric.go b/sdk/metric/export/metric.go new file mode 100644 index 00000000000..46a809a354f --- /dev/null +++ b/sdk/metric/export/metric.go @@ -0,0 +1,343 @@ +// 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 export // import "go.opentelemetry.io/otel/sdk/metric/export" + +import ( + "context" + "sync" + "time" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric/number" + "go.opentelemetry.io/otel/metric/sdkapi" + "go.opentelemetry.io/otel/sdk/instrumentation" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" + "go.opentelemetry.io/otel/sdk/resource" +) + +// Processor is responsible for deciding which kind of aggregation to +// use (via AggregatorSelector), gathering exported results from the +// SDK during collection, and deciding over which dimensions to group +// the exported data. +// +// The SDK supports binding only one of these interfaces, as it has +// the sole responsibility of determining which Aggregator to use for +// each record. +// +// The embedded AggregatorSelector interface is called (concurrently) +// in instrumentation context to select the appropriate Aggregator for +// an instrument. +// +// The `Process` method is called during collection in a +// single-threaded context from the SDK, after the aggregator is +// checkpointed, allowing the processor to build the set of metrics +// currently being exported. +type Processor interface { + // AggregatorSelector is responsible for selecting the + // concrete type of Aggregator used for a metric in the SDK. + // + // This may be a static decision based on fields of the + // Descriptor, or it could use an external configuration + // source to customize the treatment of each metric + // instrument. + // + // The result from AggregatorSelector.AggregatorFor should be + // the same type for a given Descriptor or else nil. The same + // type should be returned for a given descriptor, because + // Aggregators only know how to Merge with their own type. If + // the result is nil, the metric instrument will be disabled. + // + // Note that the SDK only calls AggregatorFor when new records + // require an Aggregator. This does not provide a way to + // disable metrics with active records. + AggregatorSelector + + // Process is called by the SDK once per internal record, + // passing the export Accumulation (a Descriptor, the corresponding + // Labels, and the checkpointed Aggregator). This call has no + // Context argument because it is expected to perform only + // computation. An SDK is not expected to call exporters from + // with Process, use a controller for that (see + // ./controllers/{pull,push}. + Process(accum Accumulation) error +} + +// AggregatorSelector supports selecting the kind of Aggregator to +// use at runtime for a specific metric instrument. +type AggregatorSelector interface { + // AggregatorFor allocates a variable number of aggregators of + // a kind suitable for the requested export. This method + // initializes a `...*Aggregator`, to support making a single + // allocation. + // + // When the call returns without initializing the *Aggregator + // to a non-nil value, the metric instrument is explicitly + // disabled. + // + // This must return a consistent type to avoid confusion in + // later stages of the metrics export process, i.e., when + // Merging or Checkpointing aggregators for a specific + // instrument. + // + // Note: This is context-free because the aggregator should + // not relate to the incoming context. This call should not + // block. + AggregatorFor(descriptor *sdkapi.Descriptor, aggregator ...*Aggregator) +} + +// Checkpointer is the interface used by a Controller to coordinate +// the Processor with Accumulator(s) and Exporter(s). The +// StartCollection() and FinishCollection() methods start and finish a +// collection interval. Controllers call the Accumulator(s) during +// collection to process Accumulations. +type Checkpointer interface { + // Processor processes metric data for export. The Process + // method is bracketed by StartCollection and FinishCollection + // calls. The embedded AggregatorSelector can be called at + // any time. + Processor + + // Reader returns the current data set. This may be + // called before and after collection. The + // implementation is required to return the same value + // throughout its lifetime, since Reader exposes a + // sync.Locker interface. The caller is responsible for + // locking the Reader before initiating collection. + Reader() Reader + + // StartCollection begins a collection interval. + StartCollection() + + // FinishCollection ends a collection interval. + FinishCollection() error +} + +// CheckpointerFactory is an interface for producing configured +// Checkpointer instances. +type CheckpointerFactory interface { + NewCheckpointer() Checkpointer +} + +// Aggregator implements a specific aggregation behavior, e.g., a +// behavior to track a sequence of updates to an instrument. Counter +// instruments commonly use a simple Sum aggregator, but for the +// distribution instruments (Histogram, GaugeObserver) there are a +// number of possible aggregators with different cost and accuracy +// tradeoffs. +// +// Note that any Aggregator may be attached to any instrument--this is +// the result of the OpenTelemetry API/SDK separation. It is possible +// to attach a Sum aggregator to a Histogram instrument. +type Aggregator interface { + // Aggregation returns an Aggregation interface to access the + // current state of this Aggregator. The caller is + // responsible for synchronization and must not call any the + // other methods in this interface concurrently while using + // the Aggregation. + Aggregation() aggregation.Aggregation + + // Update receives a new measured value and incorporates it + // into the aggregation. Update() calls may be called + // concurrently. + // + // Descriptor.NumberKind() should be consulted to determine + // whether the provided number is an int64 or float64. + // + // The Context argument comes from user-level code and could be + // inspected for a `correlation.Map` or `trace.SpanContext`. + Update(ctx context.Context, number number.Number, descriptor *sdkapi.Descriptor) error + + // SynchronizedMove is called during collection to finish one + // period of aggregation by atomically saving the + // currently-updating state into the argument Aggregator AND + // resetting the current value to the zero state. + // + // SynchronizedMove() is called concurrently with Update(). These + // two methods must be synchronized with respect to each + // other, for correctness. + // + // After saving a synchronized copy, the Aggregator can be converted + // into one or more of the interfaces in the `aggregation` sub-package, + // according to kind of Aggregator that was selected. + // + // This method will return an InconsistentAggregatorError if + // this Aggregator cannot be copied into the destination due + // to an incompatible type. + // + // This call has no Context argument because it is expected to + // perform only computation. + // + // When called with a nil `destination`, this Aggregator is reset + // and the current value is discarded. + SynchronizedMove(destination Aggregator, descriptor *sdkapi.Descriptor) error + + // Merge combines the checkpointed state from the argument + // Aggregator into this Aggregator. Merge is not synchronized + // with respect to Update or SynchronizedMove. + // + // The owner of an Aggregator being merged is responsible for + // synchronization of both Aggregator states. + Merge(aggregator Aggregator, descriptor *sdkapi.Descriptor) error +} + +// Exporter handles presentation of the checkpoint of aggregate +// metrics. This is the final stage of a metrics export pipeline, +// where metric data are formatted for a specific system. +type Exporter interface { + // Export is called immediately after completing a collection + // pass in the SDK. + // + // The Context comes from the controller that initiated + // collection. + // + // The InstrumentationLibraryReader interface refers to the + // Processor that just completed collection. + Export(ctx context.Context, resource *resource.Resource, reader InstrumentationLibraryReader) error + + // TemporalitySelector is an interface used by the Processor + // in deciding whether to compute Delta or Cumulative + // Aggregations when passing Records to this Exporter. + aggregation.TemporalitySelector +} + +// InstrumentationLibraryReader is an interface for exporters to iterate +// over one instrumentation library of metric data at a time. +type InstrumentationLibraryReader interface { + // ForEach calls the passed function once per instrumentation library, + // allowing the caller to emit metrics grouped by the library that + // produced them. + ForEach(readerFunc func(instrumentation.Library, Reader) error) error +} + +// Reader allows a controller to access a complete checkpoint of +// aggregated metrics from the Processor for a single library of +// metric data. This is passed to the Exporter which may then use +// ForEach to iterate over the collection of aggregated metrics. +type Reader interface { + // ForEach iterates over aggregated checkpoints for all + // metrics that were updated during the last collection + // period. Each aggregated checkpoint returned by the + // function parameter may return an error. + // + // The TemporalitySelector argument is used to determine + // whether the Record is computed using Delta or Cumulative + // aggregation. + // + // ForEach tolerates ErrNoData silently, as this is + // expected from the Meter implementation. Any other kind + // of error will immediately halt ForEach and return + // the error to the caller. + ForEach(tempSelector aggregation.TemporalitySelector, recordFunc func(Record) error) error + + // Locker supports locking the checkpoint set. Collection + // into the checkpoint set cannot take place (in case of a + // stateful processor) while it is locked. + // + // The Processor attached to the Accumulator MUST be called + // with the lock held. + sync.Locker + + // RLock acquires a read lock corresponding to this Locker. + RLock() + // RUnlock releases a read lock corresponding to this Locker. + RUnlock() +} + +// Metadata contains the common elements for exported metric data that +// are shared by the Accumulator->Processor and Processor->Exporter +// steps. +type Metadata struct { + descriptor *sdkapi.Descriptor + labels *attribute.Set +} + +// Accumulation contains the exported data for a single metric instrument +// and label set, as prepared by an Accumulator for the Processor. +type Accumulation struct { + Metadata + aggregator Aggregator +} + +// Record contains the exported data for a single metric instrument +// and label set, as prepared by the Processor for the Exporter. +// This includes the effective start and end time for the aggregation. +type Record struct { + Metadata + aggregation aggregation.Aggregation + start time.Time + end time.Time +} + +// Descriptor describes the metric instrument being exported. +func (m Metadata) Descriptor() *sdkapi.Descriptor { + return m.descriptor +} + +// Labels describes the labels associated with the instrument and the +// aggregated data. +func (m Metadata) Labels() *attribute.Set { + return m.labels +} + +// NewAccumulation allows Accumulator implementations to construct new +// Accumulations to send to Processors. The Descriptor, Labels, +// and Aggregator represent aggregate metric events received over a single +// collection period. +func NewAccumulation(descriptor *sdkapi.Descriptor, labels *attribute.Set, aggregator Aggregator) Accumulation { + return Accumulation{ + Metadata: Metadata{ + descriptor: descriptor, + labels: labels, + }, + aggregator: aggregator, + } +} + +// Aggregator returns the checkpointed aggregator. It is safe to +// access the checkpointed state without locking. +func (r Accumulation) Aggregator() Aggregator { + return r.aggregator +} + +// NewRecord allows Processor implementations to construct export +// records. The Descriptor, Labels, and Aggregator represent +// aggregate metric events received over a single collection period. +func NewRecord(descriptor *sdkapi.Descriptor, labels *attribute.Set, aggregation aggregation.Aggregation, start, end time.Time) Record { + return Record{ + Metadata: Metadata{ + descriptor: descriptor, + labels: labels, + }, + aggregation: aggregation, + start: start, + end: end, + } +} + +// Aggregation returns the aggregation, an interface to the record and +// its aggregator, dependent on the kind of both the input and exporter. +func (r Record) Aggregation() aggregation.Aggregation { + return r.aggregation +} + +// StartTime is the start time of the interval covered by this aggregation. +func (r Record) StartTime() time.Time { + return r.start +} + +// EndTime is the end time of the interval covered by this aggregation. +func (r Record) EndTime() time.Time { + return r.end +} diff --git a/sdk/export/metric/metric_test.go b/sdk/metric/export/metric_test.go similarity index 99% rename from sdk/export/metric/metric_test.go rename to sdk/metric/export/metric_test.go index 706e3b83a51..5337d11c9e8 100644 --- a/sdk/export/metric/metric_test.go +++ b/sdk/metric/export/metric_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package metric +package export import ( "testing" diff --git a/sdk/metric/go.mod b/sdk/metric/go.mod index a03a0ea80a3..1424e5674cf 100644 --- a/sdk/metric/go.mod +++ b/sdk/metric/go.mod @@ -47,7 +47,6 @@ require ( go.opentelemetry.io/otel/internal/metric v0.26.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 ) replace go.opentelemetry.io/otel/example/passthrough => ../../example/passthrough diff --git a/sdk/metric/processor/basic/basic.go b/sdk/metric/processor/basic/basic.go index 7ea491cf417..c86af124bb3 100644 --- a/sdk/metric/processor/basic/basic.go +++ b/sdk/metric/processor/basic/basic.go @@ -22,8 +22,8 @@ import ( "go.opentelemetry.io/otel/attribute" "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/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" ) type ( diff --git a/sdk/metric/processor/basic/basic_test.go b/sdk/metric/processor/basic/basic_test.go index a465db2c1a0..482a82a2efd 100644 --- a/sdk/metric/processor/basic/basic_test.go +++ b/sdk/metric/processor/basic/basic_test.go @@ -29,11 +29,11 @@ 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/instrumentation" sdk "go.opentelemetry.io/otel/sdk/metric" "go.opentelemetry.io/otel/sdk/metric/aggregator/aggregatortest" + "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/processor/processortest" processorTest "go.opentelemetry.io/otel/sdk/metric/processor/processortest" diff --git a/sdk/metric/processor/processortest/test.go b/sdk/metric/processor/processortest/test.go index 49e9b45662c..840af80acf7 100644 --- a/sdk/metric/processor/processortest/test.go +++ b/sdk/metric/processor/processortest/test.go @@ -23,12 +23,12 @@ import ( "go.opentelemetry.io/otel/attribute" "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" "go.opentelemetry.io/otel/sdk/metric/aggregator/histogram" "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" "go.opentelemetry.io/otel/sdk/resource" ) diff --git a/sdk/metric/processor/processortest/test_test.go b/sdk/metric/processor/processortest/test_test.go index 2ddbafc0ec8..4cc990c344a 100644 --- a/sdk/metric/processor/processortest/test_test.go +++ b/sdk/metric/processor/processortest/test_test.go @@ -22,10 +22,10 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" - export "go.opentelemetry.io/otel/sdk/export/metric" - "go.opentelemetry.io/otel/sdk/export/metric/aggregation" "go.opentelemetry.io/otel/sdk/instrumentation" metricsdk "go.opentelemetry.io/otel/sdk/metric" + "go.opentelemetry.io/otel/sdk/metric/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" "go.opentelemetry.io/otel/sdk/metric/processor/processortest" processorTest "go.opentelemetry.io/otel/sdk/metric/processor/processortest" "go.opentelemetry.io/otel/sdk/resource" diff --git a/sdk/metric/processor/reducer/reducer.go b/sdk/metric/processor/reducer/reducer.go index deb9edd34f1..b7fb4894036 100644 --- a/sdk/metric/processor/reducer/reducer.go +++ b/sdk/metric/processor/reducer/reducer.go @@ -17,7 +17,7 @@ package reducer // import "go.opentelemetry.io/otel/sdk/metric/processor/reducer import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric/sdkapi" - export "go.opentelemetry.io/otel/sdk/export/metric" + "go.opentelemetry.io/otel/sdk/metric/export" ) type ( diff --git a/sdk/metric/processor/reducer/reducer_test.go b/sdk/metric/processor/reducer/reducer_test.go index bac96ae2b6c..3da65d313ef 100644 --- a/sdk/metric/processor/reducer/reducer_test.go +++ b/sdk/metric/processor/reducer/reducer_test.go @@ -23,9 +23,9 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/sdkapi" - "go.opentelemetry.io/otel/sdk/export/metric/aggregation" "go.opentelemetry.io/otel/sdk/instrumentation" metricsdk "go.opentelemetry.io/otel/sdk/metric" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/processor/processortest" processorTest "go.opentelemetry.io/otel/sdk/metric/processor/processortest" diff --git a/sdk/metric/sdk.go b/sdk/metric/sdk.go index 998e31f6fa6..97e0d852dcd 100644 --- a/sdk/metric/sdk.go +++ b/sdk/metric/sdk.go @@ -26,8 +26,8 @@ import ( internal "go.opentelemetry.io/otel/internal/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/metric/aggregator" + "go.opentelemetry.io/otel/sdk/metric/export" ) type ( diff --git a/sdk/metric/selector/simple/simple.go b/sdk/metric/selector/simple/simple.go index 3a23be1d70c..5a8d9a23b04 100644 --- a/sdk/metric/selector/simple/simple.go +++ b/sdk/metric/selector/simple/simple.go @@ -16,10 +16,10 @@ package simple // import "go.opentelemetry.io/otel/sdk/metric/selector/simple" import ( "go.opentelemetry.io/otel/metric/sdkapi" - export "go.opentelemetry.io/otel/sdk/export/metric" "go.opentelemetry.io/otel/sdk/metric/aggregator/histogram" "go.opentelemetry.io/otel/sdk/metric/aggregator/lastvalue" "go.opentelemetry.io/otel/sdk/metric/aggregator/sum" + "go.opentelemetry.io/otel/sdk/metric/export" ) type ( diff --git a/sdk/metric/selector/simple/simple_test.go b/sdk/metric/selector/simple/simple_test.go index bd7325518e6..e47f3439414 100644 --- a/sdk/metric/selector/simple/simple_test.go +++ b/sdk/metric/selector/simple/simple_test.go @@ -22,10 +22,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/metric/aggregator/histogram" "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/selector/simple" ) diff --git a/sdk/metric/stress_test.go b/sdk/metric/stress_test.go index 229b9fe7c20..f6b9eb4ba02 100644 --- a/sdk/metric/stress_test.go +++ b/sdk/metric/stress_test.go @@ -36,8 +36,8 @@ 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/metric/export" + "go.opentelemetry.io/otel/sdk/metric/export/aggregation" "go.opentelemetry.io/otel/sdk/metric/processor/processortest" )