From f8a73d4a2d6c124a60fa530a7481a0f1b8006980 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Wed, 1 Dec 2021 18:54:11 -0800 Subject: [PATCH 01/16] Separate out OtlpMetricReaderOptions from OtlpExporterOptions --- examples/Console/TestMetrics.cs | 16 ++++--- .../.publicApi/net461/PublicAPI.Unshipped.txt | 16 +++---- .../.publicApi/net5.0/PublicAPI.Unshipped.txt | 16 +++---- .../netstandard2.0/PublicAPI.Unshipped.txt | 16 +++---- .../netstandard2.1/PublicAPI.Unshipped.txt | 16 +++---- .../OtlpExporterOptions.cs | 16 ------- .../OtlpMetricExporterExtensions.cs | 19 ++++++--- .../OtlpMetricReaderOptions.cs | 42 +++++++++++++++++++ 8 files changed, 101 insertions(+), 56 deletions(-) create mode 100644 src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricReaderOptions.cs diff --git a/examples/Console/TestMetrics.cs b/examples/Console/TestMetrics.cs index 4f726a5c6f4..16d854d4b50 100644 --- a/examples/Console/TestMetrics.cs +++ b/examples/Console/TestMetrics.cs @@ -66,12 +66,16 @@ internal static object Run(MetricsOptions options) AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); providerBuilder - .AddOtlpExporter(o => - { - o.MetricReaderType = MetricReaderType.Periodic; - o.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds; - o.AggregationTemporality = options.IsDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; - }); + .AddOtlpExporter( + exporterOptions => + { + }, + metricReaderOptions => + { + metricReaderOptions.MetricReaderType = MetricReaderType.Periodic; + metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds; + metricReaderOptions.AggregationTemporality = options.IsDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; + }); } else { diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt index ed28f69db50..60965e032b4 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt @@ -1,6 +1,4 @@ OpenTelemetry.Exporter.OtlpExporterOptions -OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.set -> void OpenTelemetry.Exporter.OtlpExporterOptions.BatchExportProcessorOptions.get -> OpenTelemetry.BatchExportProcessorOptions OpenTelemetry.Exporter.OtlpExporterOptions.BatchExportProcessorOptions.set -> void OpenTelemetry.Exporter.OtlpExporterOptions.Endpoint.get -> System.Uri @@ -9,10 +7,6 @@ OpenTelemetry.Exporter.OtlpExporterOptions.ExportProcessorType.get -> OpenTeleme OpenTelemetry.Exporter.OtlpExporterOptions.ExportProcessorType.set -> void OpenTelemetry.Exporter.OtlpExporterOptions.Headers.get -> string OpenTelemetry.Exporter.OtlpExporterOptions.Headers.set -> void -OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType -OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.set -> void -OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions -OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.set -> void OpenTelemetry.Exporter.OtlpExporterOptions.HttpClientFactory.get -> System.Func OpenTelemetry.Exporter.OtlpExporterOptions.HttpClientFactory.set -> void OpenTelemetry.Exporter.OtlpExporterOptions.OtlpExporterOptions() -> void @@ -27,11 +21,19 @@ OpenTelemetry.Exporter.OtlpMetricExporter OpenTelemetry.Exporter.OtlpMetricExporter.OtlpMetricExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void OpenTelemetry.Exporter.OtlpTraceExporter OpenTelemetry.Exporter.OtlpTraceExporter.OtlpTraceExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions +OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality +OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.set -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType +OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.set -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.OtlpMetricReaderOptions() -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions +OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void OpenTelemetry.Metrics.OtlpMetricExporterExtensions OpenTelemetry.Trace.OtlpTraceExporterHelperExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool override OpenTelemetry.Exporter.OtlpTraceExporter.Export(in OpenTelemetry.Batch activityBatch) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpTraceExporter.OnShutdown(int timeoutMilliseconds) -> bool -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null, System.Action configureMetricReader = null) -> OpenTelemetry.Metrics.MeterProviderBuilder static OpenTelemetry.Trace.OtlpTraceExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt index f59367caac1..a099c88408d 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt @@ -1,9 +1,3 @@ -OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.set -> void -OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType -OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.set -> void -OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions -OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.set -> void OpenTelemetry.Exporter.OtlpExporterOptions.HttpClientFactory.get -> System.Func OpenTelemetry.Exporter.OtlpExporterOptions.HttpClientFactory.set -> void OpenTelemetry.Exporter.OtlpExporterOptions.Protocol.get -> OpenTelemetry.Exporter.OtlpExportProtocol @@ -13,7 +7,15 @@ OpenTelemetry.Exporter.OtlpExportProtocol.Grpc = 0 -> OpenTelemetry.Exporter.Otl OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf = 1 -> OpenTelemetry.Exporter.OtlpExportProtocol OpenTelemetry.Exporter.OtlpMetricExporter OpenTelemetry.Exporter.OtlpMetricExporter.OtlpMetricExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions +OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality +OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.set -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType +OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.set -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.OtlpMetricReaderOptions() -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions +OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null, System.Action configureMetricReader = null) -> OpenTelemetry.Metrics.MeterProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index f59367caac1..a099c88408d 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,9 +1,3 @@ -OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.set -> void -OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType -OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.set -> void -OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions -OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.set -> void OpenTelemetry.Exporter.OtlpExporterOptions.HttpClientFactory.get -> System.Func OpenTelemetry.Exporter.OtlpExporterOptions.HttpClientFactory.set -> void OpenTelemetry.Exporter.OtlpExporterOptions.Protocol.get -> OpenTelemetry.Exporter.OtlpExportProtocol @@ -13,7 +7,15 @@ OpenTelemetry.Exporter.OtlpExportProtocol.Grpc = 0 -> OpenTelemetry.Exporter.Otl OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf = 1 -> OpenTelemetry.Exporter.OtlpExportProtocol OpenTelemetry.Exporter.OtlpMetricExporter OpenTelemetry.Exporter.OtlpMetricExporter.OtlpMetricExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions +OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality +OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.set -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType +OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.set -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.OtlpMetricReaderOptions() -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions +OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null, System.Action configureMetricReader = null) -> OpenTelemetry.Metrics.MeterProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt index f59367caac1..a099c88408d 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt @@ -1,9 +1,3 @@ -OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.set -> void -OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType -OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.set -> void -OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions -OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.set -> void OpenTelemetry.Exporter.OtlpExporterOptions.HttpClientFactory.get -> System.Func OpenTelemetry.Exporter.OtlpExporterOptions.HttpClientFactory.set -> void OpenTelemetry.Exporter.OtlpExporterOptions.Protocol.get -> OpenTelemetry.Exporter.OtlpExportProtocol @@ -13,7 +7,15 @@ OpenTelemetry.Exporter.OtlpExportProtocol.Grpc = 0 -> OpenTelemetry.Exporter.Otl OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf = 1 -> OpenTelemetry.Exporter.OtlpExportProtocol OpenTelemetry.Exporter.OtlpMetricExporter OpenTelemetry.Exporter.OtlpMetricExporter.OtlpMetricExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions +OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality +OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.set -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType +OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.set -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.OtlpMetricReaderOptions() -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions +OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null, System.Action configureMetricReader = null) -> OpenTelemetry.Metrics.MeterProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs index a5725b9ba6c..b0a3c7cc13b 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs @@ -119,22 +119,6 @@ public OtlpExporterOptions() /// public BatchExportProcessorOptions BatchExportProcessorOptions { get; set; } = new BatchExportActivityProcessorOptions(); - /// - /// Gets or sets the to use. Defaults to MetricReaderType.Periodic. - /// - public MetricReaderType MetricReaderType { get; set; } = MetricReaderType.Periodic; - - /// - /// Gets or sets the options. Ignored unless MetricReaderType is Periodic. - /// - public PeriodicExportingMetricReaderOptions PeriodicExportingMetricReaderOptions { get; set; } = new PeriodicExportingMetricReaderOptions(); - - /// - /// Gets or sets the AggregationTemporality used for Histogram - /// and Sum metrics. - /// - public AggregationTemporality AggregationTemporality { get; set; } = AggregationTemporality.Cumulative; - /// /// Gets or sets the factory function called to create the instance that will be used at runtime to diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs index 80a551aeacf..7a541d702d8 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs @@ -30,8 +30,12 @@ public static class OtlpMetricExporterExtensions /// /// builder to use. /// Exporter configuration options. + /// configuration options. /// The instance of to chain the calls. - public static MeterProviderBuilder AddOtlpExporter(this MeterProviderBuilder builder, Action configure = null) + public static MeterProviderBuilder AddOtlpExporter( + this MeterProviderBuilder builder, + Action configure = null, + Action configureMetricReader = null) { Guard.Null(builder, nameof(builder)); @@ -39,22 +43,25 @@ public static MeterProviderBuilder AddOtlpExporter(this MeterProviderBuilder bui { return deferredMeterProviderBuilder.Configure((sp, builder) => { - AddOtlpExporter(builder, sp.GetOptions(), configure, sp); + AddOtlpExporter(builder, sp.GetOptions(), sp.GetOptions(), configure, configureMetricReader, sp); }); } - return AddOtlpExporter(builder, new OtlpExporterOptions(), configure, serviceProvider: null); + return AddOtlpExporter(builder, new OtlpExporterOptions(), new OtlpMetricReaderOptions(), configure, configureMetricReader, serviceProvider: null); } private static MeterProviderBuilder AddOtlpExporter( MeterProviderBuilder builder, OtlpExporterOptions options, + OtlpMetricReaderOptions metricReaderOptions, Action configure, + Action configureMetricReader, IServiceProvider serviceProvider) { var initialEndpoint = options.Endpoint; configure?.Invoke(options); + configureMetricReader?.Invoke(metricReaderOptions); options.TryEnableIHttpClientFactoryIntegration(serviceProvider, "OtlpMetricExporter"); @@ -62,11 +69,11 @@ private static MeterProviderBuilder AddOtlpExporter( var metricExporter = new OtlpMetricExporter(options); - var metricReader = options.MetricReaderType == MetricReaderType.Manual + var metricReader = metricReaderOptions.MetricReaderType == MetricReaderType.Manual ? new BaseExportingMetricReader(metricExporter) - : new PeriodicExportingMetricReader(metricExporter, options.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds); + : new PeriodicExportingMetricReader(metricExporter, metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds); - metricReader.Temporality = options.AggregationTemporality; + metricReader.Temporality = metricReaderOptions.AggregationTemporality; return builder.AddReader(metricReader); } } diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricReaderOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricReaderOptions.cs new file mode 100644 index 00000000000..6a2bba5657d --- /dev/null +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricReaderOptions.cs @@ -0,0 +1,42 @@ +// +// 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. +// + +using OpenTelemetry.Metrics; + +namespace OpenTelemetry.Exporter; + +/// +/// Options for configuring the used in conjunction with an . +/// This is meant to be used with the MeterProviderBuilder.AddOtlpExporter() extension method. +/// +public class OtlpMetricReaderOptions +{ + /// + /// Gets or sets the AggregationTemporality used for Histogram + /// and Sum metrics. + /// + public AggregationTemporality AggregationTemporality { get; set; } = AggregationTemporality.Cumulative; + + /// + /// Gets or sets the to use. Defaults to MetricReaderType.Manual. + /// + public MetricReaderType MetricReaderType { get; set; } = MetricReaderType.Manual; + + /// + /// Gets or sets the options. Ignored unless MetricReaderType is Periodic. + /// + public PeriodicExportingMetricReaderOptions PeriodicExportingMetricReaderOptions { get; set; } = new PeriodicExportingMetricReaderOptions(); +} From 04a3169924a84f574175009523d6fa6b4dd160b0 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Wed, 1 Dec 2021 19:00:02 -0800 Subject: [PATCH 02/16] Collapse config delegates into one --- examples/Console/TestMetrics.cs | 16 +++--- .../.publicApi/net461/PublicAPI.Unshipped.txt | 4 +- .../.publicApi/net5.0/PublicAPI.Unshipped.txt | 4 +- .../netstandard2.0/PublicAPI.Unshipped.txt | 4 +- .../netstandard2.1/PublicAPI.Unshipped.txt | 4 +- .../OtlpMetricExporterExtensions.cs | 51 ++++++++++++++++--- 6 files changed, 61 insertions(+), 22 deletions(-) diff --git a/examples/Console/TestMetrics.cs b/examples/Console/TestMetrics.cs index 16d854d4b50..f8fe16c1fab 100644 --- a/examples/Console/TestMetrics.cs +++ b/examples/Console/TestMetrics.cs @@ -66,16 +66,12 @@ internal static object Run(MetricsOptions options) AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); providerBuilder - .AddOtlpExporter( - exporterOptions => - { - }, - metricReaderOptions => - { - metricReaderOptions.MetricReaderType = MetricReaderType.Periodic; - metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds; - metricReaderOptions.AggregationTemporality = options.IsDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; - }); + .AddOtlpExporter((exporterOptions, metricReaderOptions) => + { + metricReaderOptions.MetricReaderType = MetricReaderType.Periodic; + metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds; + metricReaderOptions.AggregationTemporality = options.IsDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; + }); } else { diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt index 60965e032b4..8f38011370d 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt @@ -35,5 +35,7 @@ override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool override OpenTelemetry.Exporter.OtlpTraceExporter.Export(in OpenTelemetry.Batch activityBatch) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpTraceExporter.OnShutdown(int timeoutMilliseconds) -> bool -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null, System.Action configureMetricReader = null) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder static OpenTelemetry.Trace.OtlpTraceExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt index a099c88408d..da436c88085 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt @@ -18,4 +18,6 @@ OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOpti OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null, System.Action configureMetricReader = null) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index a099c88408d..da436c88085 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -18,4 +18,6 @@ OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOpti OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null, System.Action configureMetricReader = null) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt index a099c88408d..da436c88085 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt @@ -18,4 +18,6 @@ OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOpti OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null, System.Action configureMetricReader = null) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs index 7a541d702d8..5ea20dabb41 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs @@ -25,17 +25,46 @@ namespace OpenTelemetry.Metrics /// public static class OtlpMetricExporterExtensions { + /// + /// Adds to the using default options. + /// + /// builder to use. + /// The instance of to chain the calls. + public static MeterProviderBuilder AddOtlpExporter(this MeterProviderBuilder builder) + { + return AddOtlpExporter(builder, options => { }); + } + /// /// Adds to the . /// /// builder to use. /// Exporter configuration options. - /// configuration options. + /// The instance of to chain the calls. + public static MeterProviderBuilder AddOtlpExporter(this MeterProviderBuilder builder, Action configure) + { + Guard.Null(builder, nameof(builder)); + + if (builder is IDeferredMeterProviderBuilder deferredMeterProviderBuilder) + { + return deferredMeterProviderBuilder.Configure((sp, builder) => + { + AddOtlpExporter(builder, sp.GetOptions(), sp.GetOptions(), configure, null, sp); + }); + } + + return AddOtlpExporter(builder, new OtlpExporterOptions(), new OtlpMetricReaderOptions(), configure, null, serviceProvider: null); + } + + /// + /// Adds to the . + /// + /// builder to use. + /// Exporter and configuration options. /// The instance of to chain the calls. public static MeterProviderBuilder AddOtlpExporter( this MeterProviderBuilder builder, - Action configure = null, - Action configureMetricReader = null) + Action configure) { Guard.Null(builder, nameof(builder)); @@ -43,11 +72,11 @@ public static MeterProviderBuilder AddOtlpExporter( { return deferredMeterProviderBuilder.Configure((sp, builder) => { - AddOtlpExporter(builder, sp.GetOptions(), sp.GetOptions(), configure, configureMetricReader, sp); + AddOtlpExporter(builder, sp.GetOptions(), sp.GetOptions(), null, configure, sp); }); } - return AddOtlpExporter(builder, new OtlpExporterOptions(), new OtlpMetricReaderOptions(), configure, configureMetricReader, serviceProvider: null); + return AddOtlpExporter(builder, new OtlpExporterOptions(), new OtlpMetricReaderOptions(), null, configure, serviceProvider: null); } private static MeterProviderBuilder AddOtlpExporter( @@ -55,13 +84,19 @@ private static MeterProviderBuilder AddOtlpExporter( OtlpExporterOptions options, OtlpMetricReaderOptions metricReaderOptions, Action configure, - Action configureMetricReader, + Action configureExporterAndMetricReader, IServiceProvider serviceProvider) { var initialEndpoint = options.Endpoint; - configure?.Invoke(options); - configureMetricReader?.Invoke(metricReaderOptions); + if (configureExporterAndMetricReader != null) + { + configureExporterAndMetricReader.Invoke(options, metricReaderOptions); + } + else + { + configure?.Invoke(options); + } options.TryEnableIHttpClientFactoryIntegration(serviceProvider, "OtlpMetricExporter"); From af019675a822d78a273612291b424b03c7402a21 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Thu, 2 Dec 2021 15:07:59 -0800 Subject: [PATCH 03/16] Rename AggregationTemporality to Temporatlity --- examples/Console/TestMetrics.cs | 2 +- .../OtlpMetricExporterExtensions.cs | 2 +- .../OtlpMetricReaderOptions.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/Console/TestMetrics.cs b/examples/Console/TestMetrics.cs index f8fe16c1fab..52557cca0f7 100644 --- a/examples/Console/TestMetrics.cs +++ b/examples/Console/TestMetrics.cs @@ -70,7 +70,7 @@ internal static object Run(MetricsOptions options) { metricReaderOptions.MetricReaderType = MetricReaderType.Periodic; metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds; - metricReaderOptions.AggregationTemporality = options.IsDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; + metricReaderOptions.Temporality = options.IsDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; }); } else diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs index 5ea20dabb41..2e868ddcab2 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs @@ -108,7 +108,7 @@ private static MeterProviderBuilder AddOtlpExporter( ? new BaseExportingMetricReader(metricExporter) : new PeriodicExportingMetricReader(metricExporter, metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds); - metricReader.Temporality = metricReaderOptions.AggregationTemporality; + metricReader.Temporality = metricReaderOptions.Temporality; return builder.AddReader(metricReader); } } diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricReaderOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricReaderOptions.cs index 6a2bba5657d..16900c7221c 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricReaderOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricReaderOptions.cs @@ -28,7 +28,7 @@ public class OtlpMetricReaderOptions /// Gets or sets the AggregationTemporality used for Histogram /// and Sum metrics. /// - public AggregationTemporality AggregationTemporality { get; set; } = AggregationTemporality.Cumulative; + public AggregationTemporality Temporality { get; set; } = AggregationTemporality.Cumulative; /// /// Gets or sets the to use. Defaults to MetricReaderType.Manual. From ccfa14634433c975e31db54c8cbf206899060a68 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Thu, 2 Dec 2021 16:27:52 -0800 Subject: [PATCH 04/16] Update public API --- .../.publicApi/net461/PublicAPI.Unshipped.txt | 4 ++-- .../.publicApi/net5.0/PublicAPI.Unshipped.txt | 4 ++-- .../.publicApi/netstandard2.0/PublicAPI.Unshipped.txt | 4 ++-- .../.publicApi/netstandard2.1/PublicAPI.Unshipped.txt | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt index 8f38011370d..d6bdc50ca4a 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt @@ -22,13 +22,13 @@ OpenTelemetry.Exporter.OtlpMetricExporter.OtlpMetricExporter(OpenTelemetry.Expor OpenTelemetry.Exporter.OtlpTraceExporter OpenTelemetry.Exporter.OtlpTraceExporter.OtlpTraceExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions -OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.set -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.set -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions.OtlpMetricReaderOptions() -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality +OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.set -> void OpenTelemetry.Metrics.OtlpMetricExporterExtensions OpenTelemetry.Trace.OtlpTraceExporterHelperExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt index da436c88085..2b82671b242 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt @@ -8,13 +8,13 @@ OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf = 1 -> OpenTelemetry.Expo OpenTelemetry.Exporter.OtlpMetricExporter OpenTelemetry.Exporter.OtlpMetricExporter.OtlpMetricExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions -OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.set -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.set -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions.OtlpMetricReaderOptions() -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality +OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.set -> void OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index da436c88085..2b82671b242 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -8,13 +8,13 @@ OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf = 1 -> OpenTelemetry.Expo OpenTelemetry.Exporter.OtlpMetricExporter OpenTelemetry.Exporter.OtlpMetricExporter.OtlpMetricExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions -OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.set -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.set -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions.OtlpMetricReaderOptions() -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality +OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.set -> void OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt index da436c88085..2b82671b242 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt @@ -8,13 +8,13 @@ OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf = 1 -> OpenTelemetry.Expo OpenTelemetry.Exporter.OtlpMetricExporter OpenTelemetry.Exporter.OtlpMetricExporter.OtlpMetricExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions -OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.OtlpMetricReaderOptions.AggregationTemporality.set -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.set -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions.OtlpMetricReaderOptions() -> void OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void +OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality +OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.set -> void OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool From 6e4bb9880926910c174868dc716aa936c2c00d52 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Thu, 2 Dec 2021 16:34:07 -0800 Subject: [PATCH 05/16] Change parameter names --- .../netstandard2.1/PublicAPI.Unshipped.txt | 4 +-- .../OtlpMetricExporterExtensions.cs | 32 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt index 2b82671b242..87804c89762 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt @@ -19,5 +19,5 @@ OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporter) -> OpenTelemetry.Metrics.MeterProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs index 2e868ddcab2..412ce84f91c 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs @@ -39,9 +39,9 @@ public static MeterProviderBuilder AddOtlpExporter(this MeterProviderBuilder bui /// Adds to the . /// /// builder to use. - /// Exporter configuration options. + /// Exporter configuration options. /// The instance of to chain the calls. - public static MeterProviderBuilder AddOtlpExporter(this MeterProviderBuilder builder, Action configure) + public static MeterProviderBuilder AddOtlpExporter(this MeterProviderBuilder builder, Action configureExporter) { Guard.Null(builder, nameof(builder)); @@ -49,22 +49,22 @@ public static MeterProviderBuilder AddOtlpExporter(this MeterProviderBuilder bui { return deferredMeterProviderBuilder.Configure((sp, builder) => { - AddOtlpExporter(builder, sp.GetOptions(), sp.GetOptions(), configure, null, sp); + AddOtlpExporter(builder, sp.GetOptions(), sp.GetOptions(), configureExporter, null, sp); }); } - return AddOtlpExporter(builder, new OtlpExporterOptions(), new OtlpMetricReaderOptions(), configure, null, serviceProvider: null); + return AddOtlpExporter(builder, new OtlpExporterOptions(), new OtlpMetricReaderOptions(), configureExporter, null, serviceProvider: null); } /// /// Adds to the . /// /// builder to use. - /// Exporter and configuration options. + /// Exporter and configuration options. /// The instance of to chain the calls. public static MeterProviderBuilder AddOtlpExporter( this MeterProviderBuilder builder, - Action configure) + Action configureExporterAndMetricReader) { Guard.Null(builder, nameof(builder)); @@ -72,37 +72,37 @@ public static MeterProviderBuilder AddOtlpExporter( { return deferredMeterProviderBuilder.Configure((sp, builder) => { - AddOtlpExporter(builder, sp.GetOptions(), sp.GetOptions(), null, configure, sp); + AddOtlpExporter(builder, sp.GetOptions(), sp.GetOptions(), null, configureExporterAndMetricReader, sp); }); } - return AddOtlpExporter(builder, new OtlpExporterOptions(), new OtlpMetricReaderOptions(), null, configure, serviceProvider: null); + return AddOtlpExporter(builder, new OtlpExporterOptions(), new OtlpMetricReaderOptions(), null, configureExporterAndMetricReader, serviceProvider: null); } private static MeterProviderBuilder AddOtlpExporter( MeterProviderBuilder builder, - OtlpExporterOptions options, + OtlpExporterOptions exporterOptions, OtlpMetricReaderOptions metricReaderOptions, - Action configure, + Action configureExporter, Action configureExporterAndMetricReader, IServiceProvider serviceProvider) { - var initialEndpoint = options.Endpoint; + var initialEndpoint = exporterOptions.Endpoint; if (configureExporterAndMetricReader != null) { - configureExporterAndMetricReader.Invoke(options, metricReaderOptions); + configureExporterAndMetricReader.Invoke(exporterOptions, metricReaderOptions); } else { - configure?.Invoke(options); + configureExporter?.Invoke(exporterOptions); } - options.TryEnableIHttpClientFactoryIntegration(serviceProvider, "OtlpMetricExporter"); + exporterOptions.TryEnableIHttpClientFactoryIntegration(serviceProvider, "OtlpMetricExporter"); - options.AppendExportPath(initialEndpoint, OtlpExporterOptions.MetricsExportPath); + exporterOptions.AppendExportPath(initialEndpoint, OtlpExporterOptions.MetricsExportPath); - var metricExporter = new OtlpMetricExporter(options); + var metricExporter = new OtlpMetricExporter(exporterOptions); var metricReader = metricReaderOptions.MetricReaderType == MetricReaderType.Manual ? new BaseExportingMetricReader(metricExporter) From 47334dacae7a6d2b44c9ee70bc7cded5e4c96363 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Tue, 25 Jan 2022 14:06:01 -0800 Subject: [PATCH 06/16] Move MetricReaderOptions to SDK --- .../OtlpMetricExporterExtensions.cs | 16 ++++++++-------- .../Metrics/MetricReaderOptions.cs} | 7 +++---- 2 files changed, 11 insertions(+), 12 deletions(-) rename src/{OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricReaderOptions.cs => OpenTelemetry/Metrics/MetricReaderOptions.cs} (81%) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs index c7fcc9484d3..401da49cc7b 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs @@ -49,11 +49,11 @@ public static MeterProviderBuilder AddOtlpExporter(this MeterProviderBuilder bui { return deferredMeterProviderBuilder.Configure((sp, builder) => { - AddOtlpExporter(builder, sp.GetOptions(), sp.GetOptions(), configureExporter, null, sp); + AddOtlpExporter(builder, sp.GetOptions(), sp.GetOptions(), configureExporter, null, sp); }); } - return AddOtlpExporter(builder, new OtlpExporterOptions(), new OtlpMetricReaderOptions(), configureExporter, null, serviceProvider: null); + return AddOtlpExporter(builder, new OtlpExporterOptions(), new MetricReaderOptions(), configureExporter, null, serviceProvider: null); } /// @@ -64,27 +64,27 @@ public static MeterProviderBuilder AddOtlpExporter(this MeterProviderBuilder bui /// The instance of to chain the calls. public static MeterProviderBuilder AddOtlpExporter( this MeterProviderBuilder builder, - Action configureExporterAndMetricReader) + Action configureExporterAndMetricReader) { - Guard.Null(builder, nameof(builder)); + Guard.ThrowIfNull(builder, nameof(builder)); if (builder is IDeferredMeterProviderBuilder deferredMeterProviderBuilder) { return deferredMeterProviderBuilder.Configure((sp, builder) => { - AddOtlpExporter(builder, sp.GetOptions(), sp.GetOptions(), null, configureExporterAndMetricReader, sp); + AddOtlpExporter(builder, sp.GetOptions(), sp.GetOptions(), null, configureExporterAndMetricReader, sp); }); } - return AddOtlpExporter(builder, new OtlpExporterOptions(), new OtlpMetricReaderOptions(), null, configureExporterAndMetricReader, serviceProvider: null); + return AddOtlpExporter(builder, new OtlpExporterOptions(), new MetricReaderOptions(), null, configureExporterAndMetricReader, serviceProvider: null); } private static MeterProviderBuilder AddOtlpExporter( MeterProviderBuilder builder, OtlpExporterOptions exporterOptions, - OtlpMetricReaderOptions metricReaderOptions, + MetricReaderOptions metricReaderOptions, Action configureExporter, - Action configureExporterAndMetricReader, + Action configureExporterAndMetricReader, IServiceProvider serviceProvider) { var initialEndpoint = exporterOptions.Endpoint; diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricReaderOptions.cs b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs similarity index 81% rename from src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricReaderOptions.cs rename to src/OpenTelemetry/Metrics/MetricReaderOptions.cs index 16900c7221c..1eb1e0bdd9d 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricReaderOptions.cs +++ b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs @@ -1,4 +1,4 @@ -// +// // Copyright The OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,10 +19,9 @@ namespace OpenTelemetry.Exporter; /// -/// Options for configuring the used in conjunction with an . -/// This is meant to be used with the MeterProviderBuilder.AddOtlpExporter() extension method. +/// Options for configuring a . /// -public class OtlpMetricReaderOptions +public class MetricReaderOptions { /// /// Gets or sets the AggregationTemporality used for Histogram From 6e8664116c297f66b2b52ace1b54cb6997dddd23 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Tue, 25 Jan 2022 14:52:26 -0800 Subject: [PATCH 07/16] Default OTLP metric exporter to use a periodic metric reader and cumulative temporality --- .../OtlpMetricExporterExtensions.cs | 10 ++++ .../Metrics/MetricReaderOptions.cs | 47 +++++++++++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs index 401da49cc7b..1ad256fe82d 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs @@ -104,6 +104,16 @@ private static MeterProviderBuilder AddOtlpExporter( var metricExporter = new OtlpMetricExporter(exporterOptions); + if (metricReaderOptions.Temporality == (AggregationTemporality)0) + { + metricReaderOptions.Temporality = AggregationTemporality.Cumulative; + } + + if (metricReaderOptions.MetricReaderType == (MetricReaderType)(-1)) + { + metricReaderOptions.MetricReaderType = MetricReaderType.Periodic; + } + var metricReader = metricReaderOptions.MetricReaderType == MetricReaderType.Manual ? new BaseExportingMetricReader(metricExporter) : new PeriodicExportingMetricReader(metricExporter, metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds); diff --git a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs index 1eb1e0bdd9d..e72e9f2949e 100644 --- a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs +++ b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs @@ -19,20 +19,61 @@ namespace OpenTelemetry.Exporter; /// -/// Options for configuring a . +/// Options for configuring either a or . /// public class MetricReaderOptions { + private const AggregationTemporality AggregationTemporalityUnspecified = (AggregationTemporality)0; + private const MetricReaderType MetricReaderTypeUnspecified = (MetricReaderType)(-1); + + public MetricReaderOptions() + { + this.Temporality = AggregationTemporalityUnspecified; + this.MetricReaderType = MetricReaderTypeUnspecified; + } + /// /// Gets or sets the AggregationTemporality used for Histogram /// and Sum metrics. /// - public AggregationTemporality Temporality { get; set; } = AggregationTemporality.Cumulative; + public AggregationTemporality Temporality + { + get + { + if (this.Temporality == AggregationTemporalityUnspecified) + { + this.Temporality = AggregationTemporality.Cumulative; + } + + return this.Temporality; + } + + set + { + this.Temporality = value; + } + } /// /// Gets or sets the to use. Defaults to MetricReaderType.Manual. /// - public MetricReaderType MetricReaderType { get; set; } = MetricReaderType.Manual; + public MetricReaderType MetricReaderType + { + get + { + if (this.MetricReaderType == MetricReaderTypeUnspecified) + { + this.MetricReaderType = MetricReaderType.Manual; + } + + return this.MetricReaderType; + } + + set + { + this.MetricReaderType = value; + } + } /// /// Gets or sets the options. Ignored unless MetricReaderType is Periodic. From bb27af7b718e85ca4618e1cea9fc9101594192a8 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Tue, 25 Jan 2022 15:05:26 -0800 Subject: [PATCH 08/16] Update example to configure exporter options --- examples/Console/Program.cs | 3 +++ examples/Console/TestMetrics.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/examples/Console/Program.cs b/examples/Console/Program.cs index d00d11db443..2c0468c7a7e 100644 --- a/examples/Console/Program.cs +++ b/examples/Console/Program.cs @@ -117,6 +117,9 @@ internal class MetricsOptions [Option("useExporter", Default = "console", HelpText = "Options include otlp or console.", Required = false)] public string UseExporter { get; set; } + + [Option('p', "useGrpc", HelpText = "Use gRPC or HTTP when using the OTLP exporter", Required = false, Default = true)] + public bool UseGrpc { get; set; } } [Verb("grpc", HelpText = "Specify the options required to test Grpc.Net.Client")] diff --git a/examples/Console/TestMetrics.cs b/examples/Console/TestMetrics.cs index 3a3fe2fe2b4..3e20efcc541 100644 --- a/examples/Console/TestMetrics.cs +++ b/examples/Console/TestMetrics.cs @@ -21,6 +21,7 @@ using System.Threading; using System.Threading.Tasks; using OpenTelemetry; +using OpenTelemetry.Exporter; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; @@ -68,6 +69,8 @@ internal static object Run(MetricsOptions options) providerBuilder .AddOtlpExporter((exporterOptions, metricReaderOptions) => { + exporterOptions.Protocol = options.UseGrpc ? OtlpExportProtocol.Grpc : OtlpExportProtocol.HttpProtobuf; + metricReaderOptions.MetricReaderType = MetricReaderType.Periodic; metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds; metricReaderOptions.Temporality = options.IsDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; From 0e71ea53d6bd673a070c689abc08b4f4e2076d71 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Tue, 25 Jan 2022 15:09:34 -0800 Subject: [PATCH 09/16] Update public API --- .../.publicApi/net461/PublicAPI.Unshipped.txt | 4 ++-- .../.publicApi/net5.0/PublicAPI.Unshipped.txt | 4 ++-- .../.publicApi/netstandard2.0/PublicAPI.Unshipped.txt | 4 ++-- .../.publicApi/netstandard2.1/PublicAPI.Unshipped.txt | 2 +- .../.publicApi/net461/PublicAPI.Unshipped.txt | 8 ++++++++ .../.publicApi/netstandard2.0/PublicAPI.Unshipped.txt | 8 ++++++++ 6 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt index d6bdc50ca4a..00719dff7e5 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt @@ -36,6 +36,6 @@ override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMillise override OpenTelemetry.Exporter.OtlpTraceExporter.Export(in OpenTelemetry.Batch activityBatch) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpTraceExporter.OnShutdown(int timeoutMilliseconds) -> bool static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporter) -> OpenTelemetry.Metrics.MeterProviderBuilder static OpenTelemetry.Trace.OtlpTraceExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt index 2b82671b242..5e48b80c47e 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt @@ -19,5 +19,5 @@ OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporter) -> OpenTelemetry.Metrics.MeterProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index 2b82671b242..5e48b80c47e 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -19,5 +19,5 @@ OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporter) -> OpenTelemetry.Metrics.MeterProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt index 87804c89762..5e48b80c47e 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt @@ -19,5 +19,5 @@ OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporter) -> OpenTelemetry.Metrics.MeterProviderBuilder diff --git a/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt index 6d964985981..5e45d2f3e11 100644 --- a/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt @@ -1,6 +1,14 @@ OpenTelemetry.BaseExporter.ForceFlush(int timeoutMilliseconds = -1) -> bool OpenTelemetry.Batch.Batch(T[] items, int count) -> void OpenTelemetry.Batch.Count.get -> long +OpenTelemetry.Exporter.MetricReaderOptions +OpenTelemetry.Exporter.MetricReaderOptions.MetricReaderOptions() -> void +OpenTelemetry.Exporter.MetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType +OpenTelemetry.Exporter.MetricReaderOptions.MetricReaderType.set -> void +OpenTelemetry.Exporter.MetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions +OpenTelemetry.Exporter.MetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void +OpenTelemetry.Exporter.MetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality +OpenTelemetry.Exporter.MetricReaderOptions.Temporality.set -> void OpenTelemetry.Metrics.AggregationTemporality OpenTelemetry.Metrics.AggregationTemporality.Cumulative = 1 -> OpenTelemetry.Metrics.AggregationTemporality OpenTelemetry.Metrics.AggregationTemporality.Delta = 2 -> OpenTelemetry.Metrics.AggregationTemporality diff --git a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index 6d964985981..5e45d2f3e11 100644 --- a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,6 +1,14 @@ OpenTelemetry.BaseExporter.ForceFlush(int timeoutMilliseconds = -1) -> bool OpenTelemetry.Batch.Batch(T[] items, int count) -> void OpenTelemetry.Batch.Count.get -> long +OpenTelemetry.Exporter.MetricReaderOptions +OpenTelemetry.Exporter.MetricReaderOptions.MetricReaderOptions() -> void +OpenTelemetry.Exporter.MetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType +OpenTelemetry.Exporter.MetricReaderOptions.MetricReaderType.set -> void +OpenTelemetry.Exporter.MetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions +OpenTelemetry.Exporter.MetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void +OpenTelemetry.Exporter.MetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality +OpenTelemetry.Exporter.MetricReaderOptions.Temporality.set -> void OpenTelemetry.Metrics.AggregationTemporality OpenTelemetry.Metrics.AggregationTemporality.Cumulative = 1 -> OpenTelemetry.Metrics.AggregationTemporality OpenTelemetry.Metrics.AggregationTemporality.Delta = 2 -> OpenTelemetry.Metrics.AggregationTemporality From e262ace64b86481b8c577bbab8faea1743f6a0ba Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Tue, 25 Jan 2022 15:18:47 -0800 Subject: [PATCH 10/16] Everyone loves a good stackoverflow --- .../Metrics/MetricReaderOptions.cs | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs index e72e9f2949e..540e94ad5df 100644 --- a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs +++ b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs @@ -25,12 +25,8 @@ public class MetricReaderOptions { private const AggregationTemporality AggregationTemporalityUnspecified = (AggregationTemporality)0; private const MetricReaderType MetricReaderTypeUnspecified = (MetricReaderType)(-1); - - public MetricReaderOptions() - { - this.Temporality = AggregationTemporalityUnspecified; - this.MetricReaderType = MetricReaderTypeUnspecified; - } + private AggregationTemporality temporality = AggregationTemporalityUnspecified; + private MetricReaderType metricReaderType = MetricReaderTypeUnspecified; /// /// Gets or sets the AggregationTemporality used for Histogram @@ -40,17 +36,17 @@ public AggregationTemporality Temporality { get { - if (this.Temporality == AggregationTemporalityUnspecified) + if (this.temporality == AggregationTemporalityUnspecified) { - this.Temporality = AggregationTemporality.Cumulative; + this.temporality = AggregationTemporality.Cumulative; } - return this.Temporality; + return this.temporality; } set { - this.Temporality = value; + this.temporality = value; } } @@ -61,17 +57,17 @@ public MetricReaderType MetricReaderType { get { - if (this.MetricReaderType == MetricReaderTypeUnspecified) + if (this.metricReaderType == MetricReaderTypeUnspecified) { - this.MetricReaderType = MetricReaderType.Manual; + this.metricReaderType = MetricReaderType.Manual; } - return this.MetricReaderType; + return this.metricReaderType; } set { - this.MetricReaderType = value; + this.metricReaderType = value; } } From 5bf0a00beac65887e6639306d9f57cdb1d91720c Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Tue, 25 Jan 2022 16:11:22 -0800 Subject: [PATCH 11/16] Update public API --- .../.publicApi/net461/PublicAPI.Unshipped.txt | 8 -------- .../.publicApi/net5.0/PublicAPI.Unshipped.txt | 8 -------- .../.publicApi/netstandard2.0/PublicAPI.Unshipped.txt | 8 -------- .../.publicApi/netstandard2.1/PublicAPI.Unshipped.txt | 8 -------- 4 files changed, 32 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt index 00719dff7e5..10a24194714 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt @@ -21,14 +21,6 @@ OpenTelemetry.Exporter.OtlpMetricExporter OpenTelemetry.Exporter.OtlpMetricExporter.OtlpMetricExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void OpenTelemetry.Exporter.OtlpTraceExporter OpenTelemetry.Exporter.OtlpTraceExporter.OtlpTraceExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions -OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType -OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.set -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions.OtlpMetricReaderOptions() -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions -OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.set -> void OpenTelemetry.Metrics.OtlpMetricExporterExtensions OpenTelemetry.Trace.OtlpTraceExporterHelperExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt index 5e48b80c47e..d672ce8ad8a 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt @@ -7,14 +7,6 @@ OpenTelemetry.Exporter.OtlpExportProtocol.Grpc = 0 -> OpenTelemetry.Exporter.Otl OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf = 1 -> OpenTelemetry.Exporter.OtlpExportProtocol OpenTelemetry.Exporter.OtlpMetricExporter OpenTelemetry.Exporter.OtlpMetricExporter.OtlpMetricExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions -OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType -OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.set -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions.OtlpMetricReaderOptions() -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions -OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.set -> void OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index 5e48b80c47e..d672ce8ad8a 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -7,14 +7,6 @@ OpenTelemetry.Exporter.OtlpExportProtocol.Grpc = 0 -> OpenTelemetry.Exporter.Otl OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf = 1 -> OpenTelemetry.Exporter.OtlpExportProtocol OpenTelemetry.Exporter.OtlpMetricExporter OpenTelemetry.Exporter.OtlpMetricExporter.OtlpMetricExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions -OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType -OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.set -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions.OtlpMetricReaderOptions() -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions -OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.set -> void OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt index 5e48b80c47e..d672ce8ad8a 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt @@ -7,14 +7,6 @@ OpenTelemetry.Exporter.OtlpExportProtocol.Grpc = 0 -> OpenTelemetry.Exporter.Otl OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf = 1 -> OpenTelemetry.Exporter.OtlpExportProtocol OpenTelemetry.Exporter.OtlpMetricExporter OpenTelemetry.Exporter.OtlpMetricExporter.OtlpMetricExporter(OpenTelemetry.Exporter.OtlpExporterOptions options) -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions -OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType -OpenTelemetry.Exporter.OtlpMetricReaderOptions.MetricReaderType.set -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions.OtlpMetricReaderOptions() -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions -OpenTelemetry.Exporter.OtlpMetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void -OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.OtlpMetricReaderOptions.Temporality.set -> void OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool From 1638313ae9647ef619569186adbf39d2c0161b41 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Thu, 17 Feb 2022 15:27:05 -0800 Subject: [PATCH 12/16] Fix bad merge --- .../OtlpMetricExporterExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs index dc67b1e1147..c8289896fdc 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs @@ -98,7 +98,7 @@ private static MeterProviderBuilder AddOtlpExporter( exporterOptions.TryEnableIHttpClientFactoryIntegration(serviceProvider, "OtlpMetricExporter"); - options.AppendExportPath(OtlpExporterOptions.MetricsExportPath); + exporterOptions.AppendExportPath(OtlpExporterOptions.MetricsExportPath); var metricExporter = new OtlpMetricExporter(exporterOptions); From 6b80dfb3734a33593cddf9f9bba4754e79db1f03 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Thu, 17 Feb 2022 15:27:33 -0800 Subject: [PATCH 13/16] Change namespace --- src/OpenTelemetry/Metrics/MetricReaderOptions.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs index 540e94ad5df..c2e7a8156d3 100644 --- a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs +++ b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs @@ -14,9 +14,7 @@ // limitations under the License. // -using OpenTelemetry.Metrics; - -namespace OpenTelemetry.Exporter; +namespace OpenTelemetry.Metrics; /// /// Options for configuring either a or . From d9dc04d164f7dc6b2895a8c6d61053f5b675d551 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Thu, 17 Feb 2022 16:15:22 -0800 Subject: [PATCH 14/16] Fix the public API --- .../.publicApi/net461/PublicAPI.Unshipped.txt | 16 ++++++++-------- .../netstandard2.0/PublicAPI.Unshipped.txt | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt index a70643b3b20..bee50adc683 100644 --- a/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt @@ -1,14 +1,14 @@ OpenTelemetry.BaseExporter.ForceFlush(int timeoutMilliseconds = -1) -> bool OpenTelemetry.Batch.Batch(T[] items, int count) -> void OpenTelemetry.Batch.Count.get -> long -OpenTelemetry.Exporter.MetricReaderOptions -OpenTelemetry.Exporter.MetricReaderOptions.MetricReaderOptions() -> void -OpenTelemetry.Exporter.MetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType -OpenTelemetry.Exporter.MetricReaderOptions.MetricReaderType.set -> void -OpenTelemetry.Exporter.MetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions -OpenTelemetry.Exporter.MetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void -OpenTelemetry.Exporter.MetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.MetricReaderOptions.Temporality.set -> void +OpenTelemetry.Metrics.MetricReaderOptions +OpenTelemetry.Metrics.MetricReaderOptions.MetricReaderOptions() -> void +OpenTelemetry.Metrics.MetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType +OpenTelemetry.Metrics.MetricReaderOptions.MetricReaderType.set -> void +OpenTelemetry.Metrics.MetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions +OpenTelemetry.Metrics.MetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void +OpenTelemetry.Metrics.MetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality +OpenTelemetry.Metrics.MetricReaderOptions.Temporality.set -> void OpenTelemetry.Metrics.AggregationTemporality OpenTelemetry.Metrics.AggregationTemporality.Cumulative = 1 -> OpenTelemetry.Metrics.AggregationTemporality OpenTelemetry.Metrics.AggregationTemporality.Delta = 2 -> OpenTelemetry.Metrics.AggregationTemporality diff --git a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index a70643b3b20..bee50adc683 100644 --- a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,14 +1,14 @@ OpenTelemetry.BaseExporter.ForceFlush(int timeoutMilliseconds = -1) -> bool OpenTelemetry.Batch.Batch(T[] items, int count) -> void OpenTelemetry.Batch.Count.get -> long -OpenTelemetry.Exporter.MetricReaderOptions -OpenTelemetry.Exporter.MetricReaderOptions.MetricReaderOptions() -> void -OpenTelemetry.Exporter.MetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType -OpenTelemetry.Exporter.MetricReaderOptions.MetricReaderType.set -> void -OpenTelemetry.Exporter.MetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions -OpenTelemetry.Exporter.MetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void -OpenTelemetry.Exporter.MetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Exporter.MetricReaderOptions.Temporality.set -> void +OpenTelemetry.Metrics.MetricReaderOptions +OpenTelemetry.Metrics.MetricReaderOptions.MetricReaderOptions() -> void +OpenTelemetry.Metrics.MetricReaderOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType +OpenTelemetry.Metrics.MetricReaderOptions.MetricReaderType.set -> void +OpenTelemetry.Metrics.MetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions +OpenTelemetry.Metrics.MetricReaderOptions.PeriodicExportingMetricReaderOptions.set -> void +OpenTelemetry.Metrics.MetricReaderOptions.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality +OpenTelemetry.Metrics.MetricReaderOptions.Temporality.set -> void OpenTelemetry.Metrics.AggregationTemporality OpenTelemetry.Metrics.AggregationTemporality.Cumulative = 1 -> OpenTelemetry.Metrics.AggregationTemporality OpenTelemetry.Metrics.AggregationTemporality.Delta = 2 -> OpenTelemetry.Metrics.AggregationTemporality From 19d62d7c7716308a7dc9fafe7e2580a53316a1f1 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Thu, 17 Feb 2022 16:45:22 -0800 Subject: [PATCH 15/16] I :heart: trying to get the public API correct without Visual Studio --- .../.publicApi/net461/PublicAPI.Unshipped.txt | 2 +- .../.publicApi/net5.0/PublicAPI.Unshipped.txt | 2 +- .../.publicApi/netstandard2.0/PublicAPI.Unshipped.txt | 2 +- .../.publicApi/netstandard2.1/PublicAPI.Unshipped.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt index 10a24194714..a019b19a6ba 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net461/PublicAPI.Unshipped.txt @@ -28,6 +28,6 @@ override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMillise override OpenTelemetry.Exporter.OtlpTraceExporter.Export(in OpenTelemetry.Batch activityBatch) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpTraceExporter.OnShutdown(int timeoutMilliseconds) -> bool static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporter) -> OpenTelemetry.Metrics.MeterProviderBuilder static OpenTelemetry.Trace.OtlpTraceExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt index d672ce8ad8a..4e91c691456 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net5.0/PublicAPI.Unshipped.txt @@ -11,5 +11,5 @@ OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporter) -> OpenTelemetry.Metrics.MeterProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index d672ce8ad8a..4e91c691456 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -11,5 +11,5 @@ OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporter) -> OpenTelemetry.Metrics.MeterProviderBuilder diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt index d672ce8ad8a..4e91c691456 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt @@ -11,5 +11,5 @@ OpenTelemetry.Metrics.OtlpMetricExporterExtensions override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch metrics) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporter) -> OpenTelemetry.Metrics.MeterProviderBuilder From 1d149ed666f7c82febe62bb226b6e52851e27b5d Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Thu, 17 Feb 2022 22:47:03 -0800 Subject: [PATCH 16/16] Remove check for unspecified temporality --- .../OtlpMetricExporterExtensions.cs | 5 ----- .../Metrics/MetricReaderOptions.cs | 20 +------------------ 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs index c8289896fdc..118c1e89808 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricExporterExtensions.cs @@ -102,11 +102,6 @@ private static MeterProviderBuilder AddOtlpExporter( var metricExporter = new OtlpMetricExporter(exporterOptions); - if (metricReaderOptions.Temporality == (AggregationTemporality)0) - { - metricReaderOptions.Temporality = AggregationTemporality.Cumulative; - } - if (metricReaderOptions.MetricReaderType == (MetricReaderType)(-1)) { metricReaderOptions.MetricReaderType = MetricReaderType.Periodic; diff --git a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs index c2e7a8156d3..d9fe24b909d 100644 --- a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs +++ b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs @@ -21,32 +21,14 @@ namespace OpenTelemetry.Metrics; /// public class MetricReaderOptions { - private const AggregationTemporality AggregationTemporalityUnspecified = (AggregationTemporality)0; private const MetricReaderType MetricReaderTypeUnspecified = (MetricReaderType)(-1); - private AggregationTemporality temporality = AggregationTemporalityUnspecified; private MetricReaderType metricReaderType = MetricReaderTypeUnspecified; /// /// Gets or sets the AggregationTemporality used for Histogram /// and Sum metrics. /// - public AggregationTemporality Temporality - { - get - { - if (this.temporality == AggregationTemporalityUnspecified) - { - this.temporality = AggregationTemporality.Cumulative; - } - - return this.temporality; - } - - set - { - this.temporality = value; - } - } + public AggregationTemporality Temporality { get; set; } = AggregationTemporality.Cumulative; /// /// Gets or sets the to use. Defaults to MetricReaderType.Manual.