From 497ecba6140fb637478c23e352567c573610cfb8 Mon Sep 17 00:00:00 2001 From: Sean ZO Marciniak Date: Tue, 26 Oct 2021 15:31:07 +1030 Subject: [PATCH 1/5] Soft deprecate Processor in `sdk/export/metric` Help speed up development of metrics SDK for Go --- CHANGELOG.md | 5 +++ sdk/export/metric/metric.go | 1 + sdk/metric/processor/processor.go | 67 +++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 sdk/metric/processor/processor.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 91130f6f9df..e08c74f26d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - `semconv.NetAttributesFromHTTPRequest()` correctly handles IPv6 addresses. (#2285) - The simple span processor shutdown method deterministically returns the exporter error status if it simultaneously finishes when the deadline is reached. (#2290, #2289) + +### Deprecated + +- The `Processor` defined in `"go.opentelemetry.io/otel/sdk/export/metric"` has be deprecated and moved to `"go.opentelemetry.io/otel/sdk/metric/processor"` (#2273) + ## [1.0.1] - 2021-10-01 ### Fixed diff --git a/sdk/export/metric/metric.go b/sdk/export/metric/metric.go index f077f74013f..ebbb4d2156f 100644 --- a/sdk/export/metric/metric.go +++ b/sdk/export/metric/metric.go @@ -44,6 +44,7 @@ import ( // single-threaded context from the SDK, after the aggregator is // checkpointed, allowing the processor to build the set of metrics // currently being exported. +// Deprecated please use the definition defined in `sdk/metric/processor` type Processor interface { // AggregatorSelector is responsible for selecting the // concrete type of Aggregator used for a metric in the SDK. diff --git a/sdk/metric/processor/processor.go b/sdk/metric/processor/processor.go new file mode 100644 index 00000000000..40d314e8996 --- /dev/null +++ b/sdk/metric/processor/processor.go @@ -0,0 +1,67 @@ +// 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 processor // import "go.opentelemetry.io/otel/sdk/metric/processor" + +// aggregator import is temporary means to allow for soft deprecation +// of `sdk/export/metric` and will converted to `sdk/metric/aggregator` +// once the work has been done. +import aggregator "go.opentelemetry.io/otel/sdk/export/metric" + +// 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. + aggregator.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 aggregator.Accumulation) error +} From 79df27156f0ceba0cece1ba2938f5dbe07e90258 Mon Sep 17 00:00:00 2001 From: Sean ZO Marciniak Date: Wed, 27 Oct 2021 14:55:54 +1030 Subject: [PATCH 2/5] No more flags --- internal/tools/go.sum | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/tools/go.sum b/internal/tools/go.sum index e7d6cc0cb4f..e919330a6ec 100644 --- a/internal/tools/go.sum +++ b/internal/tools/go.sum @@ -401,7 +401,6 @@ github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/itchyny/go-flags v1.5.0 h1:Z5q2ist2sfDjDlExVPBrMqlsEDxDR2h4zuOElB0OEYI= github.com/itchyny/go-flags v1.5.0/go.mod h1:lenkYuCobuxLBAd/HGFE4LRoW8D3B6iXRQfWYJ+MNbA= github.com/itchyny/gojq v0.12.5 h1:6SJ1BQ1VAwJAlIvLSIZmqHP/RUEq3qfVWvsRxrqhsD0= github.com/itchyny/gojq v0.12.5/go.mod h1:3e1hZXv+Kwvdp6V9HXpVrvddiHVApi5EDZwS+zLFeiE= From a202b809f77500ef9749bab00f9d345ef077b33c Mon Sep 17 00:00:00 2001 From: Sean Marciniak <30928402+MovieStoreGuy@users.noreply.github.com> Date: Mon, 1 Nov 2021 17:33:20 +1030 Subject: [PATCH 3/5] Update sdk/export/metric/metric.go Co-authored-by: Tyler Yahn --- sdk/export/metric/metric.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/export/metric/metric.go b/sdk/export/metric/metric.go index ebbb4d2156f..90cce400c08 100644 --- a/sdk/export/metric/metric.go +++ b/sdk/export/metric/metric.go @@ -44,7 +44,9 @@ import ( // single-threaded context from the SDK, after the aggregator is // checkpointed, allowing the processor to build the set of metrics // currently being exported. -// Deprecated please use the definition defined in `sdk/metric/processor` +// +// Deprecated: The Processor declared in go.opentelemetry.io/otel/sdk/metric/processor +// should be used instead. type Processor interface { // AggregatorSelector is responsible for selecting the // concrete type of Aggregator used for a metric in the SDK. From 58d6269e92a9071e982d8bd36e7f94385a5d9fba Mon Sep 17 00:00:00 2001 From: Sean Marciniak <30928402+MovieStoreGuy@users.noreply.github.com> Date: Mon, 1 Nov 2021 17:33:32 +1030 Subject: [PATCH 4/5] Update CHANGELOG.md Co-authored-by: Tyler Yahn --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e08c74f26d5..8c1107b37a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - `semconv.NetAttributesFromHTTPRequest()` correctly handles IPv6 addresses. (#2285) - The simple span processor shutdown method deterministically returns the exporter error status if it simultaneously finishes when the deadline is reached. (#2290, #2289) - ### Deprecated - The `Processor` defined in `"go.opentelemetry.io/otel/sdk/export/metric"` has be deprecated and moved to `"go.opentelemetry.io/otel/sdk/metric/processor"` (#2273) From e64c3862ed2bab4923f274cfec9bb787e5c5c5f9 Mon Sep 17 00:00:00 2001 From: Sean Marciniak <30928402+MovieStoreGuy@users.noreply.github.com> Date: Mon, 1 Nov 2021 17:33:42 +1030 Subject: [PATCH 5/5] Update CHANGELOG.md Co-authored-by: Tyler Yahn --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c1107b37a6..cac2b1deead 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Deprecated -- The `Processor` defined in `"go.opentelemetry.io/otel/sdk/export/metric"` has be deprecated and moved to `"go.opentelemetry.io/otel/sdk/metric/processor"` (#2273) +- The `Processor` defined in `"go.opentelemetry.io/otel/sdk/export/metric"` has be deprecated and moved to `"go.opentelemetry.io/otel/sdk/metric/processor"` (#2273, #2326) ## [1.0.1] - 2021-10-01