From 9455c801a11d3342b9e27e2656b880aefc92c1f8 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 26 Apr 2022 11:19:28 -0700 Subject: [PATCH 1/3] Remove unneeded metrictest types --- sdk/metric/metrictest/alignment_test.go | 42 ------------------- sdk/metric/metrictest/exporter.go | 8 ++++ sdk/metric/metrictest/meter.go | 56 ------------------------- 3 files changed, 8 insertions(+), 98 deletions(-) delete mode 100644 sdk/metric/metrictest/alignment_test.go delete mode 100644 sdk/metric/metrictest/meter.go diff --git a/sdk/metric/metrictest/alignment_test.go b/sdk/metric/metrictest/alignment_test.go deleted file mode 100644 index 183d46bda82..00000000000 --- a/sdk/metric/metrictest/alignment_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package metrictest - -import ( - "os" - "testing" - "unsafe" - - "go.opentelemetry.io/otel/internal/internaltest" -) - -// TestMain ensures struct alignment prior to running tests. -func TestMain(m *testing.M) { - fields := []internaltest.FieldOffset{ - { - Name: "Batch.Measurments", - Offset: unsafe.Offsetof(Batch{}.Measurements), - }, - { - Name: "Measurement.Number", - Offset: unsafe.Offsetof(Measurement{}.Number), - }, - } - if !internaltest.Aligned8Byte(fields, os.Stderr) { - os.Exit(1) - } - - os.Exit(m.Run()) -} diff --git a/sdk/metric/metrictest/exporter.go b/sdk/metric/metrictest/exporter.go index e57c8664c7d..0a3f7bc36dd 100644 --- a/sdk/metric/metrictest/exporter.go +++ b/sdk/metric/metrictest/exporter.go @@ -62,6 +62,14 @@ func NewTestMeterProvider(opts ...Option) (metric.MeterProvider, *Exporter) { return c, exp } +// Library is the same as "sdk/instrumentation".Library but there is +// a package cycle to use it so it is redeclared here. +type Library struct { + InstrumentationName string + InstrumentationVersion string + SchemaURL string +} + // ExportRecord represents one collected datapoint from the Exporter. type ExportRecord struct { InstrumentName string diff --git a/sdk/metric/metrictest/meter.go b/sdk/metric/metrictest/meter.go deleted file mode 100644 index fa1c6a325a4..00000000000 --- a/sdk/metric/metrictest/meter.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package metrictest // import "go.opentelemetry.io/otel/sdk/metric/metrictest" - -import ( - "context" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/sdk/metric/number" - "go.opentelemetry.io/otel/sdk/metric/sdkapi" -) - -type ( - - // Library is the same as "sdk/instrumentation".Library but there is - // a package cycle to use it. - Library struct { - InstrumentationName string - InstrumentationVersion string - SchemaURL string - } - - Batch struct { - // Measurement needs to be aligned for 64-bit atomic operations. - Measurements []Measurement - Ctx context.Context - Attributes []attribute.KeyValue - Library Library - } - - Measurement struct { - // Number needs to be aligned for 64-bit atomic operations. - Number number.Number - Instrument sdkapi.InstrumentImpl - } -) - -// NewDescriptor is a test helper for constructing test metric -// descriptors using standard options. -func NewDescriptor(name string, ikind sdkapi.InstrumentKind, nkind number.Kind, opts ...instrument.Option) sdkapi.Descriptor { - cfg := instrument.NewConfig(opts...) - return sdkapi.NewDescriptor(name, ikind, nkind, cfg.Description(), cfg.Unit()) -} From 52a54c089c3c45d415a5fb0958471f371d007d07 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 26 Apr 2022 11:26:00 -0700 Subject: [PATCH 2/3] Add changes to changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16f3f0d0f37..5de12c87210 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The `MergeIterator.Label` method in the `go.opentelemetry.io/otel/attribute` package is deprecated. Use the equivalent `MergeIterator.Attribute` method instead. (#2790) +### Removed + +- Removed the `Batch` type from the `go.opentelemetry.io/otel/sdk/metric/metrictest` package. (#2864) +- Removed the `Measurement` type from the `go.opentelemetry.io/otel/sdk/metric/metrictest` package. (#2864) +- Removed the `NewDescriptor` function from the `go.opentelemetry.io/otel/sdk/metric/metrictest` package. (#2864) + ## [0.29.0] - 2022-04-11 ### Added From 425aead8060d650b25523014ff2670a26114125f Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 26 Apr 2022 11:31:48 -0700 Subject: [PATCH 3/3] Revert removal of NewDescriptor --- CHANGELOG.md | 1 - sdk/metric/metrictest/exporter.go | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5de12c87210..444429393c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,7 +46,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Removed the `Batch` type from the `go.opentelemetry.io/otel/sdk/metric/metrictest` package. (#2864) - Removed the `Measurement` type from the `go.opentelemetry.io/otel/sdk/metric/metrictest` package. (#2864) -- Removed the `NewDescriptor` function from the `go.opentelemetry.io/otel/sdk/metric/metrictest` package. (#2864) ## [0.29.0] - 2022-04-11 diff --git a/sdk/metric/metrictest/exporter.go b/sdk/metric/metrictest/exporter.go index 0a3f7bc36dd..e767702019a 100644 --- a/sdk/metric/metrictest/exporter.go +++ b/sdk/metric/metrictest/exporter.go @@ -20,12 +20,14 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric/instrument" "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/metric/number" processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" + "go.opentelemetry.io/otel/sdk/metric/sdkapi" selector "go.opentelemetry.io/otel/sdk/metric/selector/simple" ) @@ -186,3 +188,10 @@ func subSet(attributesA, attributesB []attribute.KeyValue) bool { } return true } + +// NewDescriptor is a test helper for constructing test metric +// descriptors using standard options. +func NewDescriptor(name string, ikind sdkapi.InstrumentKind, nkind number.Kind, opts ...instrument.Option) sdkapi.Descriptor { + cfg := instrument.NewConfig(opts...) + return sdkapi.NewDescriptor(name, ikind, nkind, cfg.Description(), cfg.Unit()) +}