From d3d9ab460c3e45896c1fad5a0dcccad64a7a8f6c Mon Sep 17 00:00:00 2001 From: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> Date: Wed, 14 Jun 2023 17:36:20 -0700 Subject: [PATCH] [Exporter.Geneva] Update OTel SDK version to 1.5.0 and remove Exemplars support (#1238) --- .../CHANGELOG.md | 7 ++++++ .../Metrics/GenevaMetricExporter.cs | 16 ++++-------- .../OpenTelemetry.Exporter.Geneva.csproj | 2 +- .../Exporter/MetricExporterBenchmarks.cs | 4 --- .../GenevaMetricExporterTests.cs | 25 ++++++++----------- 5 files changed, 23 insertions(+), 31 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md index d4d8ce95b3..7f7c5eac11 100644 --- a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +* Update OpenTelemetry SDK version to `1.5.0`. + ([#1238](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1238)) + +* Removed support for exporting `Exemplars`. This would be added back in the + `1.6.*` prerelease versions right after `1.5.0` stable version is released. + ([#1238](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1238)) + * Add named options support for `GenevaTraceExporter` and `GenevaMetricExporter`. ([#1218](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1218)) diff --git a/src/OpenTelemetry.Exporter.Geneva/Metrics/GenevaMetricExporter.cs b/src/OpenTelemetry.Exporter.Geneva/Metrics/GenevaMetricExporter.cs index 6cf233a685..8da5adb605 100644 --- a/src/OpenTelemetry.Exporter.Geneva/Metrics/GenevaMetricExporter.cs +++ b/src/OpenTelemetry.Exporter.Geneva/Metrics/GenevaMetricExporter.cs @@ -122,7 +122,7 @@ public override ExportResult Export(in Batch batch) { try { - var exemplars = metricPoint.GetExemplars(); + // var exemplars = metricPoint.GetExemplars(); switch (metric.MetricType) { @@ -136,7 +136,6 @@ public override ExportResult Export(in Batch batch) metricPoint.EndTime.ToFileTime(), // Using the endTime here as the timestamp as Geneva Metrics only allows for one field for timestamp metricPoint.Tags, metricData, - exemplars, out monitoringAccount, out metricNamespace); this.metricDataTransport.Send(MetricEventType.TLV, this.buffer, bodyLength); @@ -156,7 +155,6 @@ public override ExportResult Export(in Batch batch) metricPoint.EndTime.ToFileTime(), metricPoint.Tags, metricData, - exemplars, out monitoringAccount, out metricNamespace); this.metricDataTransport.Send(MetricEventType.TLV, this.buffer, bodyLength); @@ -176,7 +174,6 @@ public override ExportResult Export(in Batch batch) metricPoint.EndTime.ToFileTime(), metricPoint.Tags, metricData, - exemplars, out monitoringAccount, out metricNamespace); this.metricDataTransport.Send(MetricEventType.TLV, this.buffer, bodyLength); @@ -194,7 +191,6 @@ public override ExportResult Export(in Batch batch) metricPoint.EndTime.ToFileTime(), metricPoint.Tags, metricData, - exemplars, out monitoringAccount, out metricNamespace); this.metricDataTransport.Send(MetricEventType.TLV, this.buffer, bodyLength); @@ -211,7 +207,6 @@ public override ExportResult Export(in Batch batch) metricPoint.EndTime.ToFileTime(), metricPoint.Tags, metricData, - exemplars, out monitoringAccount, out metricNamespace); this.metricDataTransport.Send(MetricEventType.TLV, this.buffer, bodyLength); @@ -237,7 +232,6 @@ public override ExportResult Export(in Batch batch) count, min, max, - exemplars, out monitoringAccount, out metricNamespace); this.metricDataTransport.Send(MetricEventType.TLV, this.buffer, bodyLength); @@ -301,7 +295,6 @@ internal unsafe ushort SerializeMetricWithTLV( long timestamp, in ReadOnlyTagCollection tags, MetricData value, - Exemplar[] exemplars, out string monitoringAccount, out string metricNamespace) { @@ -328,7 +321,7 @@ internal unsafe ushort SerializeMetricWithTLV( out monitoringAccount, out metricNamespace); - SerializeExemplars(exemplars, this.buffer, ref bufferIndex); + // SerializeExemplars(exemplars, this.buffer, ref bufferIndex); SerializeMonitoringAccount(monitoringAccount, this.buffer, ref bufferIndex); @@ -361,7 +354,6 @@ internal unsafe ushort SerializeHistogramMetricWithTLV( uint count, double min, double max, - Exemplar[] exemplars, out string monitoringAccount, out string metricNamespace) { @@ -388,7 +380,7 @@ internal unsafe ushort SerializeHistogramMetricWithTLV( out monitoringAccount, out metricNamespace); - SerializeExemplars(exemplars, this.buffer, ref bufferIndex); + // SerializeExemplars(exemplars, this.buffer, ref bufferIndex); SerializeMonitoringAccount(monitoringAccount, this.buffer, ref bufferIndex); @@ -433,6 +425,7 @@ private static void SerializeMonitoringAccount(string monitoringAccount, byte[] MetricSerializer.SerializeString(buffer, ref bufferIndex, monitoringAccount); } + /* Commenting out Exemplar related code as it's removed from `1.5.0` stable version of OpenTelemetry SDK [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void SerializeExemplars(Exemplar[] exemplars, byte[] buffer, ref int bufferIndex) { @@ -548,6 +541,7 @@ private static void SerializeSingleExmeplar(Exemplar exemplar, byte[] buffer, re var exemplarLength = bufferIndex - bufferIndexForLength + 1; MetricSerializer.SerializeByte(buffer, ref bufferIndexForLength, (byte)exemplarLength); } + */ [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void SerializeNonHistogramMetricData(MetricEventType eventType, MetricData value, long timestamp, byte[] buffer, ref int bufferIndex) diff --git a/src/OpenTelemetry.Exporter.Geneva/OpenTelemetry.Exporter.Geneva.csproj b/src/OpenTelemetry.Exporter.Geneva/OpenTelemetry.Exporter.Geneva.csproj index 93599774e7..e9ab3a2a3c 100644 --- a/src/OpenTelemetry.Exporter.Geneva/OpenTelemetry.Exporter.Geneva.csproj +++ b/src/OpenTelemetry.Exporter.Geneva/OpenTelemetry.Exporter.Geneva.csproj @@ -14,7 +14,7 @@ - + diff --git a/test/OpenTelemetry.Exporter.Geneva.Benchmark/Exporter/MetricExporterBenchmarks.cs b/test/OpenTelemetry.Exporter.Geneva.Benchmark/Exporter/MetricExporterBenchmarks.cs index 976ae3d584..d41fbcd08e 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Benchmark/Exporter/MetricExporterBenchmarks.cs +++ b/test/OpenTelemetry.Exporter.Geneva.Benchmark/Exporter/MetricExporterBenchmarks.cs @@ -566,7 +566,6 @@ public void SerializeCounterMetricItemWith3Dimensions() this.counterMetricPointWith3Dimensions.EndTime.ToFileTime(), this.counterMetricPointWith3Dimensions.Tags, this.counterMetricDataWith3Dimensions, - Array.Empty(), out _, out _); } @@ -580,7 +579,6 @@ public void SerializeCounterMetricItemWith4Dimensions() this.counterMetricPointWith4Dimensions.EndTime.ToFileTime(), this.counterMetricPointWith4Dimensions.Tags, this.counterMetricDataWith4Dimensions, - Array.Empty(), out _, out _); } @@ -609,7 +607,6 @@ public void SerializeHistogramMetricItemWith3Dimensions() this.histogramCountWith3Dimensions, this.histogramMinWith3Dimensions, this.histogramMaxWith3Dimensions, - Array.Empty(), out _, out _); } @@ -626,7 +623,6 @@ public void SerializeHistogramMetricItemWith4Dimensions() this.histogramCountWith4Dimensions, this.histogramMinWith4Dimensions, this.histogramMaxWith4Dimensions, - Array.Empty(), out _, out _); } diff --git a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaMetricExporterTests.cs b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaMetricExporterTests.cs index f9b3ead921..6ff8011b97 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaMetricExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaMetricExporterTests.cs @@ -196,14 +196,13 @@ public void SuccessfulExportOnLinux() var metricDataValue = Convert.ToUInt64(metricPoint.GetSumLong()); var metricData = new MetricData { UInt64Value = metricDataValue }; - var exemplars = metricPoint.GetExemplars(); + // var exemplars = metricPoint.GetExemplars(); var bodyLength = exporter.SerializeMetricWithTLV( MetricEventType.ULongMetric, metric.Name, metricPoint.EndTime.ToFileTime(), metricPoint.Tags, metricData, - exemplars, out _, out _); @@ -354,7 +353,7 @@ public void SuccessfulSerializationWithTLV(bool testMaxLimits, bool hasExemplars if (hasExemplars) { - meterProviderBuilder.SetExemplarFilter(new AlwaysOnExemplarFilter()); + // meterProviderBuilder.SetExemplarFilter(new AlwaysOnExemplarFilter()); } if (hasFilteredTagsForExemplars) @@ -949,7 +948,8 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric, var metricPointsEnumerator = metric.GetMetricPoints().GetEnumerator(); metricPointsEnumerator.MoveNext(); var metricPoint = metricPointsEnumerator.Current; - var exemplars = metricPoint.GetExemplars(); + + // var exemplars = metricPoint.GetExemplars(); List fields = null; @@ -964,7 +964,6 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric, metricPoint.EndTime.ToFileTime(), metricPoint.Tags, metricData, - exemplars, out _, out _); @@ -990,7 +989,6 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric, metricPoint.EndTime.ToFileTime(), metricPoint.Tags, metricData, - exemplars, out _, out _); @@ -1018,7 +1016,6 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric, metricPoint.EndTime.ToFileTime(), metricPoint.Tags, metricData, - exemplars, out _, out _); @@ -1046,7 +1043,6 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric, metricPoint.EndTime.ToFileTime(), metricPoint.Tags, metricData, - exemplars, out _, out _); @@ -1081,7 +1077,6 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric, count, min, max, - exemplars, out _, out _); @@ -1120,6 +1115,7 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric, Assert.Equal(bodyLength, data.LenBody); } + /* if (exemplars.Length > 0) { var validExemplars = exemplars.Where(exemplar => exemplar.Timestamp != default).ToList(); @@ -1141,6 +1137,7 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric, AssertExemplarFilteredTagSerialization(expectedExemplar, serializedExemplar); } } + */ // Check metric name, account, and namespace var connectionStringBuilder = new ConnectionStringBuilder(exporterOptions.ConnectionString); @@ -1213,6 +1210,7 @@ private static void CheckSerializationWithTLVForSingleMetricPoint(Metric metric, Assert.Equal(dimensionsCount, dimensions.NumDimensions); } + /* private static void AssertExemplarFilteredTagSerialization(Exemplar expectedExemplar, SingleExemplar serializedExemplar) { var serializedExemplarBody = serializedExemplar.Body; @@ -1262,6 +1260,7 @@ private static void AssertExemplarFilteredTagSerialization(Exemplar expectedExem } } } + */ private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter exporter) { @@ -1269,7 +1268,8 @@ private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter var metricPointsEnumerator = metric.GetMetricPoints().GetEnumerator(); metricPointsEnumerator.MoveNext(); var metricPoint = metricPointsEnumerator.Current; - var exemplars = metricPoint.GetExemplars(); + + // var exemplars = metricPoint.GetExemplars(); UserdataV2 result = null; if (metricType == MetricType.LongSum) @@ -1282,7 +1282,6 @@ private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter metricPoint.EndTime.ToFileTime(), metricPoint.Tags, metricData, - exemplars, out _, out _); @@ -1301,7 +1300,6 @@ private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter metricPoint.EndTime.ToFileTime(), metricPoint.Tags, metricData, - exemplars, out _, out _); @@ -1322,7 +1320,6 @@ private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter metricPoint.EndTime.ToFileTime(), metricPoint.Tags, metricData, - exemplars, out _, out _); @@ -1343,7 +1340,6 @@ private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter metricPoint.EndTime.ToFileTime(), metricPoint.Tags, metricData, - exemplars, out _, out _); @@ -1371,7 +1367,6 @@ private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter count, min, max, - exemplars, out _, out _);