From 95593a038345b342611fe0f15ffb036e2c485af0 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Fri, 8 Apr 2022 12:31:07 -0700 Subject: [PATCH 01/12] Introduce MetricReaderTemporalityPreference --- examples/Console/TestMetrics.cs | 4 +- .../PeriodicExportingMetricReaderHelper.cs | 2 +- src/OpenTelemetry/Metrics/MetricReader.cs | 2 + .../Metrics/MetricReaderOptions.cs | 23 +++++++++-- test/Benchmarks/Metrics/MetricsBenchmarks.cs | 6 +-- .../OtlpMetricsExporterTests.cs | 32 +++++++-------- .../Metrics/InMemoryExporterTests.cs | 2 +- .../Metrics/MemoryEfficiencyTests.cs | 10 ++--- .../Metrics/MetricAPITest.cs | 40 +++++++++---------- .../Metrics/MultipleReadersTests.cs | 20 +++++----- 10 files changed, 80 insertions(+), 61 deletions(-) diff --git a/examples/Console/TestMetrics.cs b/examples/Console/TestMetrics.cs index b9864e81733..f7eb8daebfd 100644 --- a/examples/Console/TestMetrics.cs +++ b/examples/Console/TestMetrics.cs @@ -71,7 +71,7 @@ internal static object Run(MetricsOptions options) exporterOptions.Protocol = options.UseGrpc ? OtlpExportProtocol.Grpc : OtlpExportProtocol.HttpProtobuf; metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds; - metricReaderOptions.Temporality = options.IsDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; + metricReaderOptions.TemporalityPreference = options.IsDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; }); } else @@ -82,7 +82,7 @@ internal static object Run(MetricsOptions options) exporterOptions.Targets = ConsoleExporterOutputTargets.Console; metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds; - metricReaderOptions.Temporality = options.IsDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; + metricReaderOptions.TemporalityPreference = options.IsDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; }); } diff --git a/src/OpenTelemetry/Internal/PeriodicExportingMetricReaderHelper.cs b/src/OpenTelemetry/Internal/PeriodicExportingMetricReaderHelper.cs index 487e8aeac9d..ee6a4989bed 100644 --- a/src/OpenTelemetry/Internal/PeriodicExportingMetricReaderHelper.cs +++ b/src/OpenTelemetry/Internal/PeriodicExportingMetricReaderHelper.cs @@ -34,7 +34,7 @@ internal static PeriodicExportingMetricReader CreatePeriodicExportingMetricReade var metricReader = new PeriodicExportingMetricReader(exporter, exportInterval, exportTimeout) { - Temporality = options.Temporality, + TemporalityPreference = options.TemporalityPreference, }; return metricReader; diff --git a/src/OpenTelemetry/Metrics/MetricReader.cs b/src/OpenTelemetry/Metrics/MetricReader.cs index 1cba0474796..60c01e5be01 100644 --- a/src/OpenTelemetry/Metrics/MetricReader.cs +++ b/src/OpenTelemetry/Metrics/MetricReader.cs @@ -36,6 +36,8 @@ public abstract partial class MetricReader : IDisposable private TaskCompletionSource collectionTcs; private BaseProvider parentProvider; + public MetricReaderTemporalityPreference TemporalityPreference { get; set; } + public AggregationTemporality Temporality { get diff --git a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs index 335f71bcad6..ead638cd1a8 100644 --- a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs +++ b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs @@ -16,16 +16,33 @@ namespace OpenTelemetry.Metrics; +/// +/// Defines the behavior of a +/// with respect to . +/// +public enum MetricReaderTemporalityPreference +{ + /// + /// All aggregations are performed using cumulative temporatlity. + /// + Cumulative, + + /// + /// All measurements that are monotnic in nature are aggregated using delta temporality. + /// Aggregations of non-monotonic measurements use cumulative temporality. + /// + MonotonicDelta, +} + /// /// Options for configuring either a or . /// public class MetricReaderOptions { /// - /// Gets or sets the AggregationTemporality used for Histogram - /// and Sum metrics. + /// Gets or sets the . /// - public AggregationTemporality Temporality { get; set; } = AggregationTemporality.Cumulative; + public MetricReaderTemporalityPreference TemporalityPreference { get; set; } = MetricReaderTemporalityPreference.Cumulative; /// /// Gets the options. diff --git a/test/Benchmarks/Metrics/MetricsBenchmarks.cs b/test/Benchmarks/Metrics/MetricsBenchmarks.cs index b224944c550..dc2cbfb8991 100644 --- a/test/Benchmarks/Metrics/MetricsBenchmarks.cs +++ b/test/Benchmarks/Metrics/MetricsBenchmarks.cs @@ -61,8 +61,8 @@ public class MetricsBenchmarks private MeterProvider provider; private Meter meter; - [Params(AggregationTemporality.Cumulative, AggregationTemporality.Delta)] - public AggregationTemporality AggregationTemporality { get; set; } + [Params(MetricReaderTemporalityPreference.Cumulative, MetricReaderTemporalityPreference.MonotonicDelta)] + public MetricReaderTemporalityPreference AggregationTemporality { get; set; } [GlobalSetup] public void Setup() @@ -75,7 +75,7 @@ public void Setup() .AddInMemoryExporter(exportedItems, metricReaderOptions => { metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 1000; - metricReaderOptions.Temporality = this.AggregationTemporality; + metricReaderOptions.TemporalityPreference = this.AggregationTemporality; }) .Build(); diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs index 95a4288a33f..8f904b6b591 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs @@ -260,12 +260,12 @@ public void TestGaugeToOtlpMetric(string name, string description, string unit, } [Theory] - [InlineData("test_counter", null, null, 123, null, AggregationTemporality.Cumulative, true)] - [InlineData("test_counter", null, null, null, 123.45, AggregationTemporality.Cumulative, true)] - [InlineData("test_counter", null, null, 123, null, AggregationTemporality.Delta, true)] - [InlineData("test_counter", "description", "unit", 123, null, AggregationTemporality.Cumulative, true)] - [InlineData("test_counter", null, null, 123, null, AggregationTemporality.Delta, true, "key1", "value1", "key2", 123)] - public void TestCounterToOtlpMetric(string name, string description, string unit, long? longValue, double? doubleValue, AggregationTemporality aggregationTemporality, bool isMonotonic, params object[] keysValues) + [InlineData("test_counter", null, null, 123, null, MetricReaderTemporalityPreference.Cumulative, true)] + [InlineData("test_counter", null, null, null, 123.45, MetricReaderTemporalityPreference.Cumulative, true)] + [InlineData("test_counter", null, null, 123, null, MetricReaderTemporalityPreference.MonotonicDelta, true)] + [InlineData("test_counter", "description", "unit", 123, null, MetricReaderTemporalityPreference.Cumulative, true)] + [InlineData("test_counter", null, null, 123, null, MetricReaderTemporalityPreference.MonotonicDelta, true, "key1", "value1", "key2", 123)] + public void TestCounterToOtlpMetric(string name, string description, string unit, long? longValue, double? doubleValue, MetricReaderTemporalityPreference aggregationTemporality, bool isMonotonic, params object[] keysValues) { var metrics = new List(); @@ -274,7 +274,7 @@ public void TestCounterToOtlpMetric(string name, string description, string unit .AddMeter(meter.Name) .AddInMemoryExporter(metrics, metricReaderOptions => { - metricReaderOptions.Temporality = aggregationTemporality; + metricReaderOptions.TemporalityPreference = aggregationTemporality; }) .Build(); @@ -315,7 +315,7 @@ public void TestCounterToOtlpMetric(string name, string description, string unit Assert.Equal(isMonotonic, actual.Sum.IsMonotonic); - var otlpAggregationTemporality = aggregationTemporality == AggregationTemporality.Cumulative + var otlpAggregationTemporality = aggregationTemporality == MetricReaderTemporalityPreference.Cumulative ? OtlpMetrics.AggregationTemporality.Cumulative : OtlpMetrics.AggregationTemporality.Delta; Assert.Equal(otlpAggregationTemporality, actual.Sum.AggregationTemporality); @@ -356,12 +356,12 @@ public void TestCounterToOtlpMetric(string name, string description, string unit } [Theory] - [InlineData("test_histogram", null, null, 123, null, AggregationTemporality.Cumulative)] - [InlineData("test_histogram", null, null, null, 123.45, AggregationTemporality.Cumulative)] - [InlineData("test_histogram", null, null, 123, null, AggregationTemporality.Delta)] - [InlineData("test_histogram", "description", "unit", 123, null, AggregationTemporality.Cumulative)] - [InlineData("test_histogram", null, null, 123, null, AggregationTemporality.Delta, "key1", "value1", "key2", 123)] - public void TestHistogramToOtlpMetric(string name, string description, string unit, long? longValue, double? doubleValue, AggregationTemporality aggregationTemporality, params object[] keysValues) + [InlineData("test_histogram", null, null, 123, null, MetricReaderTemporalityPreference.Cumulative)] + [InlineData("test_histogram", null, null, null, 123.45, MetricReaderTemporalityPreference.Cumulative)] + [InlineData("test_histogram", null, null, 123, null, MetricReaderTemporalityPreference.MonotonicDelta)] + [InlineData("test_histogram", "description", "unit", 123, null, MetricReaderTemporalityPreference.Cumulative)] + [InlineData("test_histogram", null, null, 123, null, MetricReaderTemporalityPreference.MonotonicDelta, "key1", "value1", "key2", 123)] + public void TestHistogramToOtlpMetric(string name, string description, string unit, long? longValue, double? doubleValue, MetricReaderTemporalityPreference aggregationTemporality, params object[] keysValues) { var metrics = new List(); @@ -370,7 +370,7 @@ public void TestHistogramToOtlpMetric(string name, string description, string un .AddMeter(meter.Name) .AddInMemoryExporter(metrics, metricReaderOptions => { - metricReaderOptions.Temporality = aggregationTemporality; + metricReaderOptions.TemporalityPreference = aggregationTemporality; }) .Build(); @@ -409,7 +409,7 @@ public void TestHistogramToOtlpMetric(string name, string description, string un Assert.Null(actual.ExponentialHistogram); Assert.Null(actual.Summary); - var otlpAggregationTemporality = aggregationTemporality == AggregationTemporality.Cumulative + var otlpAggregationTemporality = aggregationTemporality == MetricReaderTemporalityPreference.Cumulative ? OtlpMetrics.AggregationTemporality.Cumulative : OtlpMetrics.AggregationTemporality.Delta; Assert.Equal(otlpAggregationTemporality, actual.Histogram.AggregationTemporality); diff --git a/test/OpenTelemetry.Tests/Metrics/InMemoryExporterTests.cs b/test/OpenTelemetry.Tests/Metrics/InMemoryExporterTests.cs index 0573ad703f6..cec3e08f20a 100644 --- a/test/OpenTelemetry.Tests/Metrics/InMemoryExporterTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/InMemoryExporterTests.cs @@ -33,7 +33,7 @@ public void InMemoryExporterShouldDeepCopyMetricPoints() .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.Temporality = AggregationTemporality.Delta; + metricReaderOptions.TemporalityPreference = MetricReaderTemporalityPreference.MonotonicDelta; }) .Build(); diff --git a/test/OpenTelemetry.Tests/Metrics/MemoryEfficiencyTests.cs b/test/OpenTelemetry.Tests/Metrics/MemoryEfficiencyTests.cs index 646cc634249..656b768996b 100644 --- a/test/OpenTelemetry.Tests/Metrics/MemoryEfficiencyTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/MemoryEfficiencyTests.cs @@ -24,9 +24,9 @@ namespace OpenTelemetry.Metrics.Tests public class MemoryEfficiencyTests { [Theory] - [InlineData(AggregationTemporality.Cumulative)] - [InlineData(AggregationTemporality.Delta)] - public void ExportOnlyWhenPointChanged(AggregationTemporality temporality) + [InlineData(MetricReaderTemporalityPreference.Cumulative)] + [InlineData(MetricReaderTemporalityPreference.MonotonicDelta)] + public void ExportOnlyWhenPointChanged(MetricReaderTemporalityPreference temporality) { using var meter = new Meter($"{Utils.GetCurrentMethodName()}.{temporality}"); @@ -36,7 +36,7 @@ public void ExportOnlyWhenPointChanged(AggregationTemporality temporality) .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.Temporality = temporality; + metricReaderOptions.TemporalityPreference = temporality; }) .Build(); @@ -48,7 +48,7 @@ public void ExportOnlyWhenPointChanged(AggregationTemporality temporality) exportedItems.Clear(); meterProvider.ForceFlush(); - if (temporality == AggregationTemporality.Cumulative) + if (temporality == MetricReaderTemporalityPreference.Cumulative) { Assert.Single(exportedItems); } diff --git a/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs b/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs index 69417ac1f63..43777767e3e 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs @@ -669,11 +669,11 @@ public void DuplicateInstrumentNamesFromDifferentMetersWithSameNameDifferentVers } [Theory] - [InlineData(AggregationTemporality.Cumulative, true)] - [InlineData(AggregationTemporality.Cumulative, false)] - [InlineData(AggregationTemporality.Delta, true)] - [InlineData(AggregationTemporality.Delta, false)] - public void DuplicateInstrumentNamesFromDifferentMetersAreAllowed(AggregationTemporality temporality, bool hasView) + [InlineData(MetricReaderTemporalityPreference.Cumulative, true)] + [InlineData(MetricReaderTemporalityPreference.Cumulative, false)] + [InlineData(MetricReaderTemporalityPreference.MonotonicDelta, true)] + [InlineData(MetricReaderTemporalityPreference.MonotonicDelta, false)] + public void DuplicateInstrumentNamesFromDifferentMetersAreAllowed(MetricReaderTemporalityPreference temporality, bool hasView) { var exportedItems = new List(); @@ -684,7 +684,7 @@ public void DuplicateInstrumentNamesFromDifferentMetersAreAllowed(AggregationTem .AddMeter(meter2.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.Temporality = temporality; + metricReaderOptions.TemporalityPreference = temporality; }); if (hasView) @@ -805,7 +805,7 @@ public void CounterAggregationTest(bool exportDelta) .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.Temporality = exportDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; + metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; }) .Build(); @@ -907,7 +907,7 @@ public void ObservableCounterAggregationTest(bool exportDelta) .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.Temporality = exportDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; + metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; }) .Build(); @@ -981,7 +981,7 @@ public void ObservableCounterWithTagsAggregationTest(bool exportDelta) .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.Temporality = exportDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; + metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; }) .Build(); @@ -1078,7 +1078,7 @@ public void ObservableCounterSpatialAggregationTest(bool exportDelta) .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.Temporality = exportDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; + metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; }) .AddView("requestCount", new MetricStreamConfiguration() { TagKeys = Array.Empty() }) .Build(); @@ -1117,7 +1117,7 @@ public void DimensionsAreOrderInsensitiveWithSortedKeysFirst(bool exportDelta) .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.Temporality = exportDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; + metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; }) .Build(); @@ -1208,7 +1208,7 @@ public void DimensionsAreOrderInsensitiveWithUnsortedKeysFirst(bool exportDelta) .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.Temporality = exportDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative; + metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; }) .Build(); @@ -1287,9 +1287,9 @@ public void DimensionsAreOrderInsensitiveWithUnsortedKeysFirst(bool exportDelta) } [Theory] - [InlineData(AggregationTemporality.Cumulative)] - [InlineData(AggregationTemporality.Delta)] - public void TestInstrumentDisposal(AggregationTemporality temporality) + [InlineData(MetricReaderTemporalityPreference.Cumulative)] + [InlineData(MetricReaderTemporalityPreference.MonotonicDelta)] + public void TestInstrumentDisposal(MetricReaderTemporalityPreference temporality) { var exportedItems = new List(); @@ -1302,7 +1302,7 @@ public void TestInstrumentDisposal(AggregationTemporality temporality) .AddMeter(meter2.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.Temporality = temporality; + metricReaderOptions.TemporalityPreference = temporality; }) .Build(); @@ -1342,9 +1342,9 @@ public void TestInstrumentDisposal(AggregationTemporality temporality) } [Theory] - [InlineData(AggregationTemporality.Cumulative)] - [InlineData(AggregationTemporality.Delta)] - public void TestMetricPointCap(AggregationTemporality temporality) + [InlineData(MetricReaderTemporalityPreference.Cumulative)] + [InlineData(MetricReaderTemporalityPreference.MonotonicDelta)] + public void TestMetricPointCap(MetricReaderTemporalityPreference temporality) { var exportedItems = new List(); @@ -1369,7 +1369,7 @@ int MetricPointCount() .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.Temporality = temporality; + metricReaderOptions.TemporalityPreference = temporality; }) .Build(); diff --git a/test/OpenTelemetry.Tests/Metrics/MultipleReadersTests.cs b/test/OpenTelemetry.Tests/Metrics/MultipleReadersTests.cs index 00a5d1ae5c5..d523fad6016 100644 --- a/test/OpenTelemetry.Tests/Metrics/MultipleReadersTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/MultipleReadersTests.cs @@ -24,11 +24,11 @@ namespace OpenTelemetry.Metrics.Tests public class MultipleReadersTests { [Theory] - [InlineData(AggregationTemporality.Delta, false)] - [InlineData(AggregationTemporality.Delta, true)] - [InlineData(AggregationTemporality.Cumulative, false)] - [InlineData(AggregationTemporality.Cumulative, true)] - public void SdkSupportsMultipleReaders(AggregationTemporality aggregationTemporality, bool hasViews) + [InlineData(MetricReaderTemporalityPreference.MonotonicDelta, false)] + [InlineData(MetricReaderTemporalityPreference.MonotonicDelta, true)] + [InlineData(MetricReaderTemporalityPreference.Cumulative, false)] + [InlineData(MetricReaderTemporalityPreference.Cumulative, true)] + public void SdkSupportsMultipleReaders(MetricReaderTemporalityPreference aggregationTemporality, bool hasViews) { var exportedItems1 = new List(); var exportedItems2 = new List(); @@ -51,11 +51,11 @@ public void SdkSupportsMultipleReaders(AggregationTemporality aggregationTempora .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems1, metricReaderOptions => { - metricReaderOptions.Temporality = AggregationTemporality.Delta; + metricReaderOptions.TemporalityPreference = MetricReaderTemporalityPreference.MonotonicDelta; }) .AddInMemoryExporter(exportedItems2, metricReaderOptions => { - metricReaderOptions.Temporality = aggregationTemporality; + metricReaderOptions.TemporalityPreference = aggregationTemporality; }); if (hasViews) @@ -107,7 +107,7 @@ public void SdkSupportsMultipleReaders(AggregationTemporality aggregationTempora // Check value exported for ObservableCounter AssertLongSumValueForMetric(exportedItems1[2], 1000); - if (aggregationTemporality == AggregationTemporality.Delta) + if (aggregationTemporality == MetricReaderTemporalityPreference.MonotonicDelta) { AssertLongSumValueForMetric(exportedItems2[2], 1200); } @@ -128,7 +128,7 @@ public void SdkSupportsMultipleReaders(AggregationTemporality aggregationTempora // Check value exported for Counter AssertLongSumValueForMetric(exportedItems1[0], 15); - if (aggregationTemporality == AggregationTemporality.Delta) + if (aggregationTemporality == MetricReaderTemporalityPreference.MonotonicDelta) { AssertLongSumValueForMetric(exportedItems2[0], 15); } @@ -143,7 +143,7 @@ public void SdkSupportsMultipleReaders(AggregationTemporality aggregationTempora // Check value exported for ObservableCounter AssertLongSumValueForMetric(exportedItems1[2], 300); - if (aggregationTemporality == AggregationTemporality.Delta) + if (aggregationTemporality == MetricReaderTemporalityPreference.MonotonicDelta) { AssertLongSumValueForMetric(exportedItems2[2], 200); } From 8e215ce321d1c8cbdf82611778ede0c08d1f600b Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Fri, 8 Apr 2022 13:38:37 -0700 Subject: [PATCH 02/12] Use MetricReaderTemporalityPreference --- src/OpenTelemetry/Metrics/MetricReader.cs | 50 +++++++++++++++++++- src/OpenTelemetry/Metrics/MetricReaderExt.cs | 9 +++- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry/Metrics/MetricReader.cs b/src/OpenTelemetry/Metrics/MetricReader.cs index 60c01e5be01..e30d4fdd529 100644 --- a/src/OpenTelemetry/Metrics/MetricReader.cs +++ b/src/OpenTelemetry/Metrics/MetricReader.cs @@ -16,6 +16,7 @@ using System; using System.Diagnostics; +using System.Diagnostics.Metrics; using System.Threading; using System.Threading.Tasks; using OpenTelemetry.Internal; @@ -28,15 +29,62 @@ namespace OpenTelemetry.Metrics public abstract partial class MetricReader : IDisposable { private const AggregationTemporality AggregationTemporalityUnspecified = (AggregationTemporality)0; + + private static Func cumulativeTemporatlityPreferenceFunc = + (instrumentType) => AggregationTemporality.Cumulative; + + private static Func monotonicDeltaTemporatlityPreferenceFunc = (instrumentType) => + { + return instrumentType.GetGenericTypeDefinition() switch + { + var type when type == typeof(Counter<>) => AggregationTemporality.Delta, + var type when type == typeof(ObservableCounter<>) => AggregationTemporality.Delta, + var type when type == typeof(Histogram<>) => AggregationTemporality.Delta, + + // Temporatlity is not defined for gauges, so this does not really affect anything. + var type when type == typeof(ObservableGauge<>) => AggregationTemporality.Delta, + + // With .NET 7 the OpenTelemetry .NET SDK will support UpDownCounters. + // These will be aggregated using Cumulative temporatlity. + // See: + // https://docs.microsoft.com/dotnet/api/system.diagnostics.metrics.updowncounter-1 + // https://docs.microsoft.com/dotnet/api/system.diagnostics.metrics.observableupdowncounter-1 + // var type when type == typeof(UpDownCounter<>) => AggregationTemporality.Cumulative, + // var type when type == typeof(ObservableUpDownCounter<>) => AggregationTemporality.Cumulative, + + // TODO: Consider logging here because we should not fall through to this case. + _ => AggregationTemporality.Delta, + }; + }; + private readonly object newTaskLock = new(); private readonly object onCollectLock = new(); private readonly TaskCompletionSource shutdownTcs = new(); private AggregationTemporality temporality = AggregationTemporalityUnspecified; + private MetricReaderTemporalityPreference temporalityPreference = MetricReaderTemporalityPreference.Cumulative; + private Func temporatlityFunc = cumulativeTemporatlityPreferenceFunc; private int shutdownCount; private TaskCompletionSource collectionTcs; private BaseProvider parentProvider; - public MetricReaderTemporalityPreference TemporalityPreference { get; set; } + public MetricReaderTemporalityPreference TemporalityPreference + { + get => this.temporalityPreference; + set + { + this.temporalityPreference = value; + switch (value) + { + case MetricReaderTemporalityPreference.MonotonicDelta: + this.temporatlityFunc = monotonicDeltaTemporatlityPreferenceFunc; + break; + case MetricReaderTemporalityPreference.Cumulative: + default: + this.temporatlityFunc = cumulativeTemporatlityPreferenceFunc; + break; + } + } + } public AggregationTemporality Temporality { diff --git a/src/OpenTelemetry/Metrics/MetricReaderExt.cs b/src/OpenTelemetry/Metrics/MetricReaderExt.cs index cb60edd32b4..400e55823b9 100644 --- a/src/OpenTelemetry/Metrics/MetricReaderExt.cs +++ b/src/OpenTelemetry/Metrics/MetricReaderExt.cs @@ -36,6 +36,11 @@ public abstract partial class MetricReader private Metric[] metricsCurrentBatch; private int metricIndex = -1; + internal AggregationTemporality GetAggregationTemporality(Type instrumentType) + { + return this.temporatlityFunc(instrumentType); + } + internal Metric AddMetricWithNoViews(Instrument instrument) { var meterName = instrument.Meter.Name; @@ -70,7 +75,7 @@ internal Metric AddMetricWithNoViews(Instrument instrument) Metric metric = null; try { - metric = new Metric(metricStreamIdentity, this.Temporality, this.maxMetricPointsPerMetricStream); + metric = new Metric(metricStreamIdentity, this.GetAggregationTemporality(metricStreamIdentity.InstrumentType), this.maxMetricPointsPerMetricStream); } catch (NotSupportedException nse) { @@ -170,7 +175,7 @@ internal List AddMetricsListWithViews(Instrument instrument, List Date: Fri, 8 Apr 2022 13:55:38 -0700 Subject: [PATCH 03/12] Prevent changing MetricReaderTemporalityPreference once set --- src/OpenTelemetry/Metrics/MetricReader.cs | 19 +++++++++++++++++-- .../Metrics/MetricReaderOptions.cs | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry/Metrics/MetricReader.cs b/src/OpenTelemetry/Metrics/MetricReader.cs index e30d4fdd529..1e19ca51618 100644 --- a/src/OpenTelemetry/Metrics/MetricReader.cs +++ b/src/OpenTelemetry/Metrics/MetricReader.cs @@ -29,6 +29,7 @@ namespace OpenTelemetry.Metrics public abstract partial class MetricReader : IDisposable { private const AggregationTemporality AggregationTemporalityUnspecified = (AggregationTemporality)0; + private const MetricReaderTemporalityPreference MetricReaderTemporalityPreferenceUnspecified = (MetricReaderTemporalityPreference)0; private static Func cumulativeTemporatlityPreferenceFunc = (instrumentType) => AggregationTemporality.Cumulative; @@ -61,7 +62,7 @@ public abstract partial class MetricReader : IDisposable private readonly object onCollectLock = new(); private readonly TaskCompletionSource shutdownTcs = new(); private AggregationTemporality temporality = AggregationTemporalityUnspecified; - private MetricReaderTemporalityPreference temporalityPreference = MetricReaderTemporalityPreference.Cumulative; + private MetricReaderTemporalityPreference temporalityPreference = MetricReaderTemporalityPreferenceUnspecified; private Func temporatlityFunc = cumulativeTemporatlityPreferenceFunc; private int shutdownCount; private TaskCompletionSource collectionTcs; @@ -69,9 +70,23 @@ public abstract partial class MetricReader : IDisposable public MetricReaderTemporalityPreference TemporalityPreference { - get => this.temporalityPreference; + get + { + if (this.temporalityPreference == MetricReaderTemporalityPreferenceUnspecified) + { + this.temporalityPreference = MetricReaderTemporalityPreference.Cumulative; + } + + return this.temporalityPreference; + } + set { + if (this.temporalityPreference != MetricReaderTemporalityPreferenceUnspecified) + { + throw new NotSupportedException($"The temporality preference cannot be modified (the current value is {this.temporalityPreference})."); + } + this.temporalityPreference = value; switch (value) { diff --git a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs index ead638cd1a8..1c56a3a9e7d 100644 --- a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs +++ b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs @@ -25,13 +25,13 @@ public enum MetricReaderTemporalityPreference /// /// All aggregations are performed using cumulative temporatlity. /// - Cumulative, + Cumulative = 1, /// /// All measurements that are monotnic in nature are aggregated using delta temporality. /// Aggregations of non-monotonic measurements use cumulative temporality. /// - MonotonicDelta, + MonotonicDelta = 2, } /// From 19393cc02ceaf0305199a7c97fee5294c1e06080 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Fri, 8 Apr 2022 14:03:23 -0700 Subject: [PATCH 04/12] Set MetricReaderTemporalityPreference in benchmark --- test/Benchmarks/Metrics/MetricCollectBenchmarks.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Benchmarks/Metrics/MetricCollectBenchmarks.cs b/test/Benchmarks/Metrics/MetricCollectBenchmarks.cs index a7e27ea9d65..c90ca299956 100644 --- a/test/Benchmarks/Metrics/MetricCollectBenchmarks.cs +++ b/test/Benchmarks/Metrics/MetricCollectBenchmarks.cs @@ -88,7 +88,7 @@ void ProcessExport(Batch batch) this.reader = new BaseExportingMetricReader(metricExporter) { - Temporality = AggregationTemporality.Cumulative, + TemporalityPreference = MetricReaderTemporalityPreference.Cumulative, }; this.meter = new Meter(Utils.GetCurrentMethodName()); From b6a0566887124ede950d02156a53b1b8c5c44d00 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Fri, 8 Apr 2022 15:25:51 -0700 Subject: [PATCH 05/12] Remove MetricReader.Temporality and AggregationTemporalityAttribute --- .../PrometheusExporter.cs | 1 - ...sExporterMeterProviderBuilderExtensions.cs | 1 + .../AggregationTemporalityAttribute.cs | 33 ------------------- .../Metrics/BaseExportingMetricReader.cs | 9 +---- src/OpenTelemetry/Metrics/MetricReader.cs | 25 -------------- 5 files changed, 2 insertions(+), 67 deletions(-) delete mode 100644 src/OpenTelemetry/Metrics/AggregationTemporalityAttribute.cs diff --git a/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporter.cs b/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporter.cs index e49c5d16831..4af4eb17fc9 100644 --- a/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporter.cs +++ b/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporter.cs @@ -23,7 +23,6 @@ namespace OpenTelemetry.Exporter /// /// Exporter of OpenTelemetry metrics to Prometheus. /// - [AggregationTemporality(AggregationTemporality.Cumulative)] [ExportModes(ExportModes.Pull)] public class PrometheusExporter : BaseExporter, IPullMetricExporter { diff --git a/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporterMeterProviderBuilderExtensions.cs b/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporterMeterProviderBuilderExtensions.cs index 6d42926589a..ada7d1c90d1 100644 --- a/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporterMeterProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporterMeterProviderBuilderExtensions.cs @@ -49,6 +49,7 @@ private static MeterProviderBuilder AddPrometheusExporter(MeterProviderBuilder b var exporter = new PrometheusExporter(options); var reader = new BaseExportingMetricReader(exporter); + reader.TemporalityPreference = MetricReaderTemporalityPreference.Cumulative; return builder.AddReader(reader); } diff --git a/src/OpenTelemetry/Metrics/AggregationTemporalityAttribute.cs b/src/OpenTelemetry/Metrics/AggregationTemporalityAttribute.cs deleted file mode 100644 index 3e4c7e9b266..00000000000 --- a/src/OpenTelemetry/Metrics/AggregationTemporalityAttribute.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -using System; - -namespace OpenTelemetry.Metrics -{ - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] - public sealed class AggregationTemporalityAttribute : Attribute - { - private readonly AggregationTemporality temporality; - - public AggregationTemporalityAttribute(AggregationTemporality temporality) - { - this.temporality = temporality; - } - - public AggregationTemporality Temporality => this.temporality; - } -} diff --git a/src/OpenTelemetry/Metrics/BaseExportingMetricReader.cs b/src/OpenTelemetry/Metrics/BaseExportingMetricReader.cs index 526df4ee941..647025fd719 100644 --- a/src/OpenTelemetry/Metrics/BaseExportingMetricReader.cs +++ b/src/OpenTelemetry/Metrics/BaseExportingMetricReader.cs @@ -45,14 +45,7 @@ public BaseExportingMetricReader(BaseExporter exporter) this.exporter = exporter; var exportorType = exporter.GetType(); - var attributes = exportorType.GetCustomAttributes(typeof(AggregationTemporalityAttribute), true); - if (attributes.Length > 0) - { - var attr = (AggregationTemporalityAttribute)attributes[attributes.Length - 1]; - this.Temporality = attr.Temporality; - } - - attributes = exportorType.GetCustomAttributes(typeof(ExportModesAttribute), true); + var attributes = exportorType.GetCustomAttributes(typeof(ExportModesAttribute), true); if (attributes.Length > 0) { var attr = (ExportModesAttribute)attributes[attributes.Length - 1]; diff --git a/src/OpenTelemetry/Metrics/MetricReader.cs b/src/OpenTelemetry/Metrics/MetricReader.cs index 1e19ca51618..764d6695677 100644 --- a/src/OpenTelemetry/Metrics/MetricReader.cs +++ b/src/OpenTelemetry/Metrics/MetricReader.cs @@ -28,7 +28,6 @@ namespace OpenTelemetry.Metrics /// public abstract partial class MetricReader : IDisposable { - private const AggregationTemporality AggregationTemporalityUnspecified = (AggregationTemporality)0; private const MetricReaderTemporalityPreference MetricReaderTemporalityPreferenceUnspecified = (MetricReaderTemporalityPreference)0; private static Func cumulativeTemporatlityPreferenceFunc = @@ -61,7 +60,6 @@ public abstract partial class MetricReader : IDisposable private readonly object newTaskLock = new(); private readonly object onCollectLock = new(); private readonly TaskCompletionSource shutdownTcs = new(); - private AggregationTemporality temporality = AggregationTemporalityUnspecified; private MetricReaderTemporalityPreference temporalityPreference = MetricReaderTemporalityPreferenceUnspecified; private Func temporatlityFunc = cumulativeTemporatlityPreferenceFunc; private int shutdownCount; @@ -101,29 +99,6 @@ public MetricReaderTemporalityPreference TemporalityPreference } } - public AggregationTemporality Temporality - { - get - { - if (this.temporality == AggregationTemporalityUnspecified) - { - this.temporality = AggregationTemporality.Cumulative; - } - - return this.temporality; - } - - set - { - if (this.temporality != AggregationTemporalityUnspecified) - { - throw new NotSupportedException($"The temporality cannot be modified (the current value is {this.temporality})."); - } - - this.temporality = value; - } - } - /// /// Attempts to collect the metrics, blocks the current thread until /// metrics collection completed, shutdown signaled or timed out. From e0b5c8ec668dda26400c3f7704120616b59756a0 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Fri, 8 Apr 2022 16:08:05 -0700 Subject: [PATCH 06/12] Move MetricReaderTemporalityPreference to its own file --- .../Metrics/MetricReaderOptions.cs | 18 ---------- .../MetricReaderTemporalityPreference.cs | 35 +++++++++++++++++++ 2 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 src/OpenTelemetry/Metrics/MetricReaderTemporalityPreference.cs diff --git a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs index 1c56a3a9e7d..da4b6f5879c 100644 --- a/src/OpenTelemetry/Metrics/MetricReaderOptions.cs +++ b/src/OpenTelemetry/Metrics/MetricReaderOptions.cs @@ -16,24 +16,6 @@ namespace OpenTelemetry.Metrics; -/// -/// Defines the behavior of a -/// with respect to . -/// -public enum MetricReaderTemporalityPreference -{ - /// - /// All aggregations are performed using cumulative temporatlity. - /// - Cumulative = 1, - - /// - /// All measurements that are monotnic in nature are aggregated using delta temporality. - /// Aggregations of non-monotonic measurements use cumulative temporality. - /// - MonotonicDelta = 2, -} - /// /// Options for configuring either a or . /// diff --git a/src/OpenTelemetry/Metrics/MetricReaderTemporalityPreference.cs b/src/OpenTelemetry/Metrics/MetricReaderTemporalityPreference.cs new file mode 100644 index 00000000000..f1644dc96b0 --- /dev/null +++ b/src/OpenTelemetry/Metrics/MetricReaderTemporalityPreference.cs @@ -0,0 +1,35 @@ +// +// 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. +// + +namespace OpenTelemetry.Metrics; + +/// +/// Defines the behavior of a +/// with respect to . +/// +public enum MetricReaderTemporalityPreference +{ + /// + /// All aggregations are performed using cumulative temporatlity. + /// + Cumulative = 1, + + /// + /// All measurements that are monotnic in nature are aggregated using delta temporality. + /// Aggregations of non-monotonic measurements use cumulative temporality. + /// + MonotonicDelta = 2, +} From 24797a039be9f5889c5afe889fc1cb6d1cc06a38 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Fri, 8 Apr 2022 16:16:08 -0700 Subject: [PATCH 07/12] Update public API --- .../.publicApi/net461/PublicAPI.Unshipped.txt | 14 +++++++------- .../netstandard2.0/PublicAPI.Unshipped.txt | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt index 9f27c359012..88d20f6ee46 100644 --- a/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt @@ -5,17 +5,14 @@ OpenTelemetry.Metrics.ExplicitBucketHistogramConfiguration OpenTelemetry.Metrics.ExplicitBucketHistogramConfiguration.Boundaries.get -> double[] OpenTelemetry.Metrics.ExplicitBucketHistogramConfiguration.Boundaries.set -> void OpenTelemetry.Metrics.ExplicitBucketHistogramConfiguration.ExplicitBucketHistogramConfiguration() -> void +OpenTelemetry.Metrics.MetricReader.TemporalityPreference.get -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference +OpenTelemetry.Metrics.MetricReader.TemporalityPreference.set -> void OpenTelemetry.Metrics.MetricReaderOptions OpenTelemetry.Metrics.MetricReaderOptions.MetricReaderOptions() -> void OpenTelemetry.Metrics.MetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions -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 -OpenTelemetry.Metrics.AggregationTemporalityAttribute -OpenTelemetry.Metrics.AggregationTemporalityAttribute.AggregationTemporalityAttribute(OpenTelemetry.Metrics.AggregationTemporality temporality) -> void -OpenTelemetry.Metrics.AggregationTemporalityAttribute.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality OpenTelemetry.Metrics.BaseExportingMetricReader OpenTelemetry.Metrics.BaseExportingMetricReader.BaseExportingMetricReader(OpenTelemetry.BaseExporter exporter) -> void OpenTelemetry.Metrics.BaseExportingMetricReader.SupportedExportModes.get -> OpenTelemetry.Metrics.ExportModes @@ -76,8 +73,11 @@ OpenTelemetry.Metrics.MetricReader.Collect(int timeoutMilliseconds = -1) -> bool OpenTelemetry.Metrics.MetricReader.Dispose() -> void OpenTelemetry.Metrics.MetricReader.MetricReader() -> void OpenTelemetry.Metrics.MetricReader.Shutdown(int timeoutMilliseconds = -1) -> bool -OpenTelemetry.Metrics.MetricReader.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Metrics.MetricReader.Temporality.set -> void +OpenTelemetry.Metrics.MetricReaderOptions.TemporalityPreference.get -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference +OpenTelemetry.Metrics.MetricReaderOptions.TemporalityPreference.set -> void +OpenTelemetry.Metrics.MetricReaderTemporalityPreference +OpenTelemetry.Metrics.MetricReaderTemporalityPreference.Cumulative = 1 -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference +OpenTelemetry.Metrics.MetricReaderTemporalityPreference.MonotonicDelta = 2 -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference OpenTelemetry.Metrics.MetricStreamConfiguration OpenTelemetry.Metrics.MetricStreamConfiguration.Description.get -> string OpenTelemetry.Metrics.MetricStreamConfiguration.Description.set -> void diff --git a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index 9f27c359012..88d20f6ee46 100644 --- a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -5,17 +5,14 @@ OpenTelemetry.Metrics.ExplicitBucketHistogramConfiguration OpenTelemetry.Metrics.ExplicitBucketHistogramConfiguration.Boundaries.get -> double[] OpenTelemetry.Metrics.ExplicitBucketHistogramConfiguration.Boundaries.set -> void OpenTelemetry.Metrics.ExplicitBucketHistogramConfiguration.ExplicitBucketHistogramConfiguration() -> void +OpenTelemetry.Metrics.MetricReader.TemporalityPreference.get -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference +OpenTelemetry.Metrics.MetricReader.TemporalityPreference.set -> void OpenTelemetry.Metrics.MetricReaderOptions OpenTelemetry.Metrics.MetricReaderOptions.MetricReaderOptions() -> void OpenTelemetry.Metrics.MetricReaderOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions -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 -OpenTelemetry.Metrics.AggregationTemporalityAttribute -OpenTelemetry.Metrics.AggregationTemporalityAttribute.AggregationTemporalityAttribute(OpenTelemetry.Metrics.AggregationTemporality temporality) -> void -OpenTelemetry.Metrics.AggregationTemporalityAttribute.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality OpenTelemetry.Metrics.BaseExportingMetricReader OpenTelemetry.Metrics.BaseExportingMetricReader.BaseExportingMetricReader(OpenTelemetry.BaseExporter exporter) -> void OpenTelemetry.Metrics.BaseExportingMetricReader.SupportedExportModes.get -> OpenTelemetry.Metrics.ExportModes @@ -76,8 +73,11 @@ OpenTelemetry.Metrics.MetricReader.Collect(int timeoutMilliseconds = -1) -> bool OpenTelemetry.Metrics.MetricReader.Dispose() -> void OpenTelemetry.Metrics.MetricReader.MetricReader() -> void OpenTelemetry.Metrics.MetricReader.Shutdown(int timeoutMilliseconds = -1) -> bool -OpenTelemetry.Metrics.MetricReader.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality -OpenTelemetry.Metrics.MetricReader.Temporality.set -> void +OpenTelemetry.Metrics.MetricReaderOptions.TemporalityPreference.get -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference +OpenTelemetry.Metrics.MetricReaderOptions.TemporalityPreference.set -> void +OpenTelemetry.Metrics.MetricReaderTemporalityPreference +OpenTelemetry.Metrics.MetricReaderTemporalityPreference.Cumulative = 1 -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference +OpenTelemetry.Metrics.MetricReaderTemporalityPreference.MonotonicDelta = 2 -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference OpenTelemetry.Metrics.MetricStreamConfiguration OpenTelemetry.Metrics.MetricStreamConfiguration.Description.get -> string OpenTelemetry.Metrics.MetricStreamConfiguration.Description.set -> void From d02eb2ba2f109d4c12358e5596fc571e6ce71124 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Tue, 12 Apr 2022 10:34:44 -0700 Subject: [PATCH 08/12] Rename MonotonicDelta to Delta --- examples/Console/TestMetrics.cs | 4 ++-- src/OpenTelemetry/Metrics/MetricReader.cs | 2 +- .../MetricReaderTemporalityPreference.cs | 2 +- test/Benchmarks/Metrics/MetricsBenchmarks.cs | 2 +- .../OtlpMetricsExporterTests.cs | 8 ++++---- .../Metrics/InMemoryExporterTests.cs | 2 +- .../Metrics/MemoryEfficiencyTests.cs | 2 +- .../Metrics/MetricAPITest.cs | 20 +++++++++---------- .../Metrics/MultipleReadersTests.cs | 12 +++++------ 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/examples/Console/TestMetrics.cs b/examples/Console/TestMetrics.cs index f7eb8daebfd..35fc3dd1324 100644 --- a/examples/Console/TestMetrics.cs +++ b/examples/Console/TestMetrics.cs @@ -71,7 +71,7 @@ internal static object Run(MetricsOptions options) exporterOptions.Protocol = options.UseGrpc ? OtlpExportProtocol.Grpc : OtlpExportProtocol.HttpProtobuf; metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds; - metricReaderOptions.TemporalityPreference = options.IsDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; + metricReaderOptions.TemporalityPreference = options.IsDelta ? MetricReaderTemporalityPreference.Delta : MetricReaderTemporalityPreference.Cumulative; }); } else @@ -82,7 +82,7 @@ internal static object Run(MetricsOptions options) exporterOptions.Targets = ConsoleExporterOutputTargets.Console; metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds; - metricReaderOptions.TemporalityPreference = options.IsDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; + metricReaderOptions.TemporalityPreference = options.IsDelta ? MetricReaderTemporalityPreference.Delta : MetricReaderTemporalityPreference.Cumulative; }); } diff --git a/src/OpenTelemetry/Metrics/MetricReader.cs b/src/OpenTelemetry/Metrics/MetricReader.cs index 764d6695677..ed3ee50d4a1 100644 --- a/src/OpenTelemetry/Metrics/MetricReader.cs +++ b/src/OpenTelemetry/Metrics/MetricReader.cs @@ -88,7 +88,7 @@ public MetricReaderTemporalityPreference TemporalityPreference this.temporalityPreference = value; switch (value) { - case MetricReaderTemporalityPreference.MonotonicDelta: + case MetricReaderTemporalityPreference.Delta: this.temporatlityFunc = monotonicDeltaTemporatlityPreferenceFunc; break; case MetricReaderTemporalityPreference.Cumulative: diff --git a/src/OpenTelemetry/Metrics/MetricReaderTemporalityPreference.cs b/src/OpenTelemetry/Metrics/MetricReaderTemporalityPreference.cs index f1644dc96b0..ad21319910f 100644 --- a/src/OpenTelemetry/Metrics/MetricReaderTemporalityPreference.cs +++ b/src/OpenTelemetry/Metrics/MetricReaderTemporalityPreference.cs @@ -31,5 +31,5 @@ public enum MetricReaderTemporalityPreference /// All measurements that are monotnic in nature are aggregated using delta temporality. /// Aggregations of non-monotonic measurements use cumulative temporality. /// - MonotonicDelta = 2, + Delta = 2, } diff --git a/test/Benchmarks/Metrics/MetricsBenchmarks.cs b/test/Benchmarks/Metrics/MetricsBenchmarks.cs index dc2cbfb8991..8e267f32c0c 100644 --- a/test/Benchmarks/Metrics/MetricsBenchmarks.cs +++ b/test/Benchmarks/Metrics/MetricsBenchmarks.cs @@ -61,7 +61,7 @@ public class MetricsBenchmarks private MeterProvider provider; private Meter meter; - [Params(MetricReaderTemporalityPreference.Cumulative, MetricReaderTemporalityPreference.MonotonicDelta)] + [Params(MetricReaderTemporalityPreference.Cumulative, MetricReaderTemporalityPreference.Delta)] public MetricReaderTemporalityPreference AggregationTemporality { get; set; } [GlobalSetup] diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs index 8f904b6b591..1f5fec6728c 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs @@ -262,9 +262,9 @@ public void TestGaugeToOtlpMetric(string name, string description, string unit, [Theory] [InlineData("test_counter", null, null, 123, null, MetricReaderTemporalityPreference.Cumulative, true)] [InlineData("test_counter", null, null, null, 123.45, MetricReaderTemporalityPreference.Cumulative, true)] - [InlineData("test_counter", null, null, 123, null, MetricReaderTemporalityPreference.MonotonicDelta, true)] + [InlineData("test_counter", null, null, 123, null, MetricReaderTemporalityPreference.Delta, true)] [InlineData("test_counter", "description", "unit", 123, null, MetricReaderTemporalityPreference.Cumulative, true)] - [InlineData("test_counter", null, null, 123, null, MetricReaderTemporalityPreference.MonotonicDelta, true, "key1", "value1", "key2", 123)] + [InlineData("test_counter", null, null, 123, null, MetricReaderTemporalityPreference.Delta, true, "key1", "value1", "key2", 123)] public void TestCounterToOtlpMetric(string name, string description, string unit, long? longValue, double? doubleValue, MetricReaderTemporalityPreference aggregationTemporality, bool isMonotonic, params object[] keysValues) { var metrics = new List(); @@ -358,9 +358,9 @@ public void TestCounterToOtlpMetric(string name, string description, string unit [Theory] [InlineData("test_histogram", null, null, 123, null, MetricReaderTemporalityPreference.Cumulative)] [InlineData("test_histogram", null, null, null, 123.45, MetricReaderTemporalityPreference.Cumulative)] - [InlineData("test_histogram", null, null, 123, null, MetricReaderTemporalityPreference.MonotonicDelta)] + [InlineData("test_histogram", null, null, 123, null, MetricReaderTemporalityPreference.Delta)] [InlineData("test_histogram", "description", "unit", 123, null, MetricReaderTemporalityPreference.Cumulative)] - [InlineData("test_histogram", null, null, 123, null, MetricReaderTemporalityPreference.MonotonicDelta, "key1", "value1", "key2", 123)] + [InlineData("test_histogram", null, null, 123, null, MetricReaderTemporalityPreference.Delta, "key1", "value1", "key2", 123)] public void TestHistogramToOtlpMetric(string name, string description, string unit, long? longValue, double? doubleValue, MetricReaderTemporalityPreference aggregationTemporality, params object[] keysValues) { var metrics = new List(); diff --git a/test/OpenTelemetry.Tests/Metrics/InMemoryExporterTests.cs b/test/OpenTelemetry.Tests/Metrics/InMemoryExporterTests.cs index cec3e08f20a..c5337ef49a6 100644 --- a/test/OpenTelemetry.Tests/Metrics/InMemoryExporterTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/InMemoryExporterTests.cs @@ -33,7 +33,7 @@ public void InMemoryExporterShouldDeepCopyMetricPoints() .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.TemporalityPreference = MetricReaderTemporalityPreference.MonotonicDelta; + metricReaderOptions.TemporalityPreference = MetricReaderTemporalityPreference.Delta; }) .Build(); diff --git a/test/OpenTelemetry.Tests/Metrics/MemoryEfficiencyTests.cs b/test/OpenTelemetry.Tests/Metrics/MemoryEfficiencyTests.cs index 656b768996b..451ec5aba80 100644 --- a/test/OpenTelemetry.Tests/Metrics/MemoryEfficiencyTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/MemoryEfficiencyTests.cs @@ -25,7 +25,7 @@ public class MemoryEfficiencyTests { [Theory] [InlineData(MetricReaderTemporalityPreference.Cumulative)] - [InlineData(MetricReaderTemporalityPreference.MonotonicDelta)] + [InlineData(MetricReaderTemporalityPreference.Delta)] public void ExportOnlyWhenPointChanged(MetricReaderTemporalityPreference temporality) { using var meter = new Meter($"{Utils.GetCurrentMethodName()}.{temporality}"); diff --git a/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs b/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs index 43777767e3e..724502d3294 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs @@ -671,8 +671,8 @@ public void DuplicateInstrumentNamesFromDifferentMetersWithSameNameDifferentVers [Theory] [InlineData(MetricReaderTemporalityPreference.Cumulative, true)] [InlineData(MetricReaderTemporalityPreference.Cumulative, false)] - [InlineData(MetricReaderTemporalityPreference.MonotonicDelta, true)] - [InlineData(MetricReaderTemporalityPreference.MonotonicDelta, false)] + [InlineData(MetricReaderTemporalityPreference.Delta, true)] + [InlineData(MetricReaderTemporalityPreference.Delta, false)] public void DuplicateInstrumentNamesFromDifferentMetersAreAllowed(MetricReaderTemporalityPreference temporality, bool hasView) { var exportedItems = new List(); @@ -805,7 +805,7 @@ public void CounterAggregationTest(bool exportDelta) .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; + metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.Delta : MetricReaderTemporalityPreference.Cumulative; }) .Build(); @@ -907,7 +907,7 @@ public void ObservableCounterAggregationTest(bool exportDelta) .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; + metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.Delta : MetricReaderTemporalityPreference.Cumulative; }) .Build(); @@ -981,7 +981,7 @@ public void ObservableCounterWithTagsAggregationTest(bool exportDelta) .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; + metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.Delta : MetricReaderTemporalityPreference.Cumulative; }) .Build(); @@ -1078,7 +1078,7 @@ public void ObservableCounterSpatialAggregationTest(bool exportDelta) .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; + metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.Delta : MetricReaderTemporalityPreference.Cumulative; }) .AddView("requestCount", new MetricStreamConfiguration() { TagKeys = Array.Empty() }) .Build(); @@ -1117,7 +1117,7 @@ public void DimensionsAreOrderInsensitiveWithSortedKeysFirst(bool exportDelta) .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; + metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.Delta : MetricReaderTemporalityPreference.Cumulative; }) .Build(); @@ -1208,7 +1208,7 @@ public void DimensionsAreOrderInsensitiveWithUnsortedKeysFirst(bool exportDelta) .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems, metricReaderOptions => { - metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.MonotonicDelta : MetricReaderTemporalityPreference.Cumulative; + metricReaderOptions.TemporalityPreference = exportDelta ? MetricReaderTemporalityPreference.Delta : MetricReaderTemporalityPreference.Cumulative; }) .Build(); @@ -1288,7 +1288,7 @@ public void DimensionsAreOrderInsensitiveWithUnsortedKeysFirst(bool exportDelta) [Theory] [InlineData(MetricReaderTemporalityPreference.Cumulative)] - [InlineData(MetricReaderTemporalityPreference.MonotonicDelta)] + [InlineData(MetricReaderTemporalityPreference.Delta)] public void TestInstrumentDisposal(MetricReaderTemporalityPreference temporality) { var exportedItems = new List(); @@ -1343,7 +1343,7 @@ public void TestInstrumentDisposal(MetricReaderTemporalityPreference temporality [Theory] [InlineData(MetricReaderTemporalityPreference.Cumulative)] - [InlineData(MetricReaderTemporalityPreference.MonotonicDelta)] + [InlineData(MetricReaderTemporalityPreference.Delta)] public void TestMetricPointCap(MetricReaderTemporalityPreference temporality) { var exportedItems = new List(); diff --git a/test/OpenTelemetry.Tests/Metrics/MultipleReadersTests.cs b/test/OpenTelemetry.Tests/Metrics/MultipleReadersTests.cs index d523fad6016..142ed9371f9 100644 --- a/test/OpenTelemetry.Tests/Metrics/MultipleReadersTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/MultipleReadersTests.cs @@ -24,8 +24,8 @@ namespace OpenTelemetry.Metrics.Tests public class MultipleReadersTests { [Theory] - [InlineData(MetricReaderTemporalityPreference.MonotonicDelta, false)] - [InlineData(MetricReaderTemporalityPreference.MonotonicDelta, true)] + [InlineData(MetricReaderTemporalityPreference.Delta, false)] + [InlineData(MetricReaderTemporalityPreference.Delta, true)] [InlineData(MetricReaderTemporalityPreference.Cumulative, false)] [InlineData(MetricReaderTemporalityPreference.Cumulative, true)] public void SdkSupportsMultipleReaders(MetricReaderTemporalityPreference aggregationTemporality, bool hasViews) @@ -51,7 +51,7 @@ public void SdkSupportsMultipleReaders(MetricReaderTemporalityPreference aggrega .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems1, metricReaderOptions => { - metricReaderOptions.TemporalityPreference = MetricReaderTemporalityPreference.MonotonicDelta; + metricReaderOptions.TemporalityPreference = MetricReaderTemporalityPreference.Delta; }) .AddInMemoryExporter(exportedItems2, metricReaderOptions => { @@ -107,7 +107,7 @@ public void SdkSupportsMultipleReaders(MetricReaderTemporalityPreference aggrega // Check value exported for ObservableCounter AssertLongSumValueForMetric(exportedItems1[2], 1000); - if (aggregationTemporality == MetricReaderTemporalityPreference.MonotonicDelta) + if (aggregationTemporality == MetricReaderTemporalityPreference.Delta) { AssertLongSumValueForMetric(exportedItems2[2], 1200); } @@ -128,7 +128,7 @@ public void SdkSupportsMultipleReaders(MetricReaderTemporalityPreference aggrega // Check value exported for Counter AssertLongSumValueForMetric(exportedItems1[0], 15); - if (aggregationTemporality == MetricReaderTemporalityPreference.MonotonicDelta) + if (aggregationTemporality == MetricReaderTemporalityPreference.Delta) { AssertLongSumValueForMetric(exportedItems2[0], 15); } @@ -143,7 +143,7 @@ public void SdkSupportsMultipleReaders(MetricReaderTemporalityPreference aggrega // Check value exported for ObservableCounter AssertLongSumValueForMetric(exportedItems1[2], 300); - if (aggregationTemporality == MetricReaderTemporalityPreference.MonotonicDelta) + if (aggregationTemporality == MetricReaderTemporalityPreference.Delta) { AssertLongSumValueForMetric(exportedItems2[2], 200); } From 326687b26482acf308d4bb06d31a54708db045e2 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Tue, 12 Apr 2022 10:53:14 -0700 Subject: [PATCH 09/12] Update changelog --- src/OpenTelemetry/CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index 05ecd026138..861bcf98175 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -2,6 +2,18 @@ ## Unreleased +* Removed the `Temporality` setting on `MetricReader` and replaced it with + `TemporalityPreference`. This is a breaking change. + `TemporalityPreference` is used to determine the `AggregationTemporality` + used on a per-instrument kind basis. Currently, there are two preferences: + * `Cumulative`: Measurements from all instrument kinds are aggregated using + `AggregationTemporality.Cumulative`. + * `Delta`: Measurements from `Counter`, `AsyncCounter`, and `Histogram` + instruments are aggregated using `AggregationTemporality.Delta`. When + UpDownCounters are supported with .NET 7, they will be aggregated using + `AggregationTemporality.Cumulative`. + ([#3153](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3153)) + * Fix issue where `ExplicitBucketHistogramConfiguration` could be used to configure metric streams for instruments that are not histograms. Currently, it is not possible to change the aggregation of an instrument with views. This From 0c49c629d9bf049a13ca22f1f3377de2e1308c50 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Tue, 12 Apr 2022 11:28:11 -0700 Subject: [PATCH 10/12] Apply suggestions from code review Co-authored-by: Cijo Thomas --- src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt | 2 +- src/OpenTelemetry/CHANGELOG.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt index 88d20f6ee46..d980f563a39 100644 --- a/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt @@ -77,7 +77,7 @@ OpenTelemetry.Metrics.MetricReaderOptions.TemporalityPreference.get -> OpenTelem OpenTelemetry.Metrics.MetricReaderOptions.TemporalityPreference.set -> void OpenTelemetry.Metrics.MetricReaderTemporalityPreference OpenTelemetry.Metrics.MetricReaderTemporalityPreference.Cumulative = 1 -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference -OpenTelemetry.Metrics.MetricReaderTemporalityPreference.MonotonicDelta = 2 -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference +OpenTelemetry.Metrics.MetricReaderTemporalityPreference.Delta = 2 -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference OpenTelemetry.Metrics.MetricStreamConfiguration OpenTelemetry.Metrics.MetricStreamConfiguration.Description.get -> string OpenTelemetry.Metrics.MetricStreamConfiguration.Description.set -> void diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index 861bcf98175..d465abcfa98 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -8,9 +8,9 @@ used on a per-instrument kind basis. Currently, there are two preferences: * `Cumulative`: Measurements from all instrument kinds are aggregated using `AggregationTemporality.Cumulative`. - * `Delta`: Measurements from `Counter`, `AsyncCounter`, and `Histogram` + * `Delta`: Measurements from `Counter`, `ObservableCounter`, and `Histogram` instruments are aggregated using `AggregationTemporality.Delta`. When - UpDownCounters are supported with .NET 7, they will be aggregated using + UpDownCounters are supported with [DiagnosticSource version 7.0 onwards](https://www.nuget.org/packages/System.Diagnostics.DiagnosticSource/7.0.0-preview.2.22152.2), they will be aggregated using `AggregationTemporality.Cumulative`. ([#3153](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3153)) From 1d2ba979c8ae20e4db768a1b3e6096bee8ad528b Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Tue, 12 Apr 2022 11:52:19 -0700 Subject: [PATCH 11/12] Update public API --- .../.publicApi/netstandard2.0/PublicAPI.Unshipped.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index 88d20f6ee46..d980f563a39 100644 --- a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -77,7 +77,7 @@ OpenTelemetry.Metrics.MetricReaderOptions.TemporalityPreference.get -> OpenTelem OpenTelemetry.Metrics.MetricReaderOptions.TemporalityPreference.set -> void OpenTelemetry.Metrics.MetricReaderTemporalityPreference OpenTelemetry.Metrics.MetricReaderTemporalityPreference.Cumulative = 1 -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference -OpenTelemetry.Metrics.MetricReaderTemporalityPreference.MonotonicDelta = 2 -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference +OpenTelemetry.Metrics.MetricReaderTemporalityPreference.Delta = 2 -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference OpenTelemetry.Metrics.MetricStreamConfiguration OpenTelemetry.Metrics.MetricStreamConfiguration.Description.get -> string OpenTelemetry.Metrics.MetricStreamConfiguration.Description.set -> void From e39beb91c5f3c840b874490d5bd5660344174f14 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Tue, 12 Apr 2022 11:54:11 -0700 Subject: [PATCH 12/12] markdownlint --- src/OpenTelemetry/CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index d465abcfa98..09922d7fded 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -10,8 +10,9 @@ `AggregationTemporality.Cumulative`. * `Delta`: Measurements from `Counter`, `ObservableCounter`, and `Histogram` instruments are aggregated using `AggregationTemporality.Delta`. When - UpDownCounters are supported with [DiagnosticSource version 7.0 onwards](https://www.nuget.org/packages/System.Diagnostics.DiagnosticSource/7.0.0-preview.2.22152.2), they will be aggregated using - `AggregationTemporality.Cumulative`. + UpDownCounters are supported with + [DiagnosticSource version 7.0 onwards](https://www.nuget.org/packages/System.Diagnostics.DiagnosticSource/7.0.0-preview.2.22152.2), + they will be aggregated using `AggregationTemporality.Cumulative`. ([#3153](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3153)) * Fix issue where `ExplicitBucketHistogramConfiguration` could be used to