From 68b7d6f963db67ae574977ae6484bb0cdb941ad2 Mon Sep 17 00:00:00 2001 From: Rajkumar Rangaraj Date: Mon, 9 Dec 2024 12:51:17 -0800 Subject: [PATCH 1/7] Update changelog --- .../CHANGELOG.md | 22 +++++++++++++++++++ .../ProtobufOtlpResourceSerializer.cs | 22 +------------------ .../OtlpHttpTraceExportClientTests.cs | 4 ++-- .../OtlpMetricsExporterTests.cs | 2 +- .../OtlpResourceTests.cs | 2 +- .../OtlpTraceExporterTests.cs | 2 +- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index d8f52e54309..3b2334e7a42 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -7,6 +7,28 @@ Notes](../../RELEASENOTES.md). ## Unreleased +* Removed the following package references: + + * `Google.Protobuf` + * `Grpc` + * `Grpc.Net.Client` + * `Grpc.Tools` + + These changes were made to streamline dependencies and reduce the footprint of the exporter. + +* Switched from using the `Google.Protobuf` library for serialization to a + custom manual implementation of protobuf serialization. + +* Fixed an issue where a `service.name` was added to the resource if it was + missing. The exporter now respects the resource data provided by the SDK + without modifications. + +* Removed the peer service resolver, which was based on earlier experimental + semantic conventions that are not part of the stable specification. This + change ensures that the exporter no longer modifies or assumes the value of + peer service attributes, aligning it more closely with OpenTelemetry protocol + specifications + ## 1.10.0 Released 2024-Nov-12 diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpResourceSerializer.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpResourceSerializer.cs index e31c4d9dd5f..d12099bec02 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpResourceSerializer.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpResourceSerializer.cs @@ -9,9 +9,6 @@ internal static class ProtobufOtlpResourceSerializer { private const int ReserveSizeForLength = 4; - private static readonly string DefaultServiceName = ResourceBuilder.CreateDefault().Build().Attributes.FirstOrDefault( - kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName).Value as string ?? "unknown_service"; - internal static int WriteResource(byte[] buffer, int writePosition, Resource? resource) { ProtobufOtlpTagWriter.OtlpTagWriterState otlpTagWriterState = new ProtobufOtlpTagWriter.OtlpTagWriterState @@ -24,41 +21,24 @@ internal static int WriteResource(byte[] buffer, int writePosition, Resource? re int resourceLengthPosition = otlpTagWriterState.WritePosition; otlpTagWriterState.WritePosition += ReserveSizeForLength; - bool isServiceNamePresent = false; if (resource != null && resource != Resource.Empty) { if (resource.Attributes is IReadOnlyList> resourceAttributesList) { for (int i = 0; i < resourceAttributesList.Count; i++) { - var attribute = resourceAttributesList[i]; - if (attribute.Key == ResourceSemanticConventions.AttributeServiceName) - { - isServiceNamePresent = true; - } - - ProcessResourceAttribute(ref otlpTagWriterState, attribute); + ProcessResourceAttribute(ref otlpTagWriterState, resourceAttributesList[i]); } } else { foreach (var attribute in resource.Attributes) { - if (attribute.Key == ResourceSemanticConventions.AttributeServiceName) - { - isServiceNamePresent = true; - } - ProcessResourceAttribute(ref otlpTagWriterState, attribute); } } } - if (!isServiceNamePresent) - { - ProcessResourceAttribute(ref otlpTagWriterState, new KeyValuePair(ResourceSemanticConventions.AttributeServiceName, DefaultServiceName)); - } - var resourceLength = otlpTagWriterState.WritePosition - (resourceLengthPosition + ReserveSizeForLength); ProtobufSerializer.WriteReservedLength(otlpTagWriterState.Buffer, resourceLengthPosition, resourceLength); diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs index e9a4ba80c76..cb774f45f95 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs @@ -172,8 +172,8 @@ void RunTest(Batch batch) Assert.Contains(resourceSpan.Resource.Attributes, (kvp) => kvp.Key == ResourceSemanticConventions.AttributeServiceNamespace && kvp.Value.StringValue == "ns_1"); } else - { - Assert.Contains(resourceSpan.Resource.Attributes, (kvp) => kvp.Key == ResourceSemanticConventions.AttributeServiceName && kvp.Value.ToString().Contains("unknown_service:")); + { + Assert.DoesNotContain(resourceSpan.Resource.Attributes, kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName); } } } diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs index d90d3934ad7..10f381e76c6 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs @@ -207,7 +207,7 @@ public void ToOtlpResourceMetricsTest(bool includeServiceNameInResource) } else { - Assert.Contains(otlpResource.Attributes, (kvp) => kvp.Key == ResourceSemanticConventions.AttributeServiceName && kvp.Value.ToString().Contains("unknown_service:")); + Assert.DoesNotContain(otlpResource.Attributes, kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName); } Assert.Single(resourceMetric.ScopeMetrics); diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpResourceTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpResourceTests.cs index 4d309326a78..5bc0c3601ae 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpResourceTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpResourceTests.cs @@ -43,7 +43,7 @@ public void ToOtlpResourceTest(bool includeServiceNameInResource) } else { - Assert.Contains(otlpResource.Attributes, (kvp) => kvp.Key == ResourceSemanticConventions.AttributeServiceName && kvp.Value.ToString().Contains("unknown_service:")); + Assert.DoesNotContain(otlpResource.Attributes, kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName); } } } diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs index 94b97ca1702..0093b6c0d3b 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs @@ -184,7 +184,7 @@ void RunTest(SdkLimitOptions sdkOptions, Batch batch) } else { - Assert.Contains(otlpResource.Attributes, (kvp) => kvp.Key == ResourceSemanticConventions.AttributeServiceName && kvp.Value.ToString().Contains("unknown_service:")); + Assert.DoesNotContain(otlpResource.Attributes, kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName); } var scopeSpans = request.ResourceSpans.First().ScopeSpans; From 2ab1c8ce09453f06e1d1c0a8d2f18bc72435f2e2 Mon Sep 17 00:00:00 2001 From: Rajkumar Rangaraj Date: Mon, 9 Dec 2024 12:55:42 -0800 Subject: [PATCH 2/7] changelog update --- .../CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 3b2334e7a42..b108853de4c 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -15,19 +15,23 @@ Notes](../../RELEASENOTES.md). * `Grpc.Tools` These changes were made to streamline dependencies and reduce the footprint of the exporter. + ([#6015](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6015)) * Switched from using the `Google.Protobuf` library for serialization to a custom manual implementation of protobuf serialization. + ([#6015](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6015)) * Fixed an issue where a `service.name` was added to the resource if it was missing. The exporter now respects the resource data provided by the SDK without modifications. + ([#6015](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6015)) * Removed the peer service resolver, which was based on earlier experimental semantic conventions that are not part of the stable specification. This change ensures that the exporter no longer modifies or assumes the value of peer service attributes, aligning it more closely with OpenTelemetry protocol - specifications + specifications. + ([#6015](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6015)) ## 1.10.0 From 35d242b20b2f4bd084a6c9c8e8b320b4b80c4324 Mon Sep 17 00:00:00 2001 From: Rajkumar Rangaraj Date: Mon, 9 Dec 2024 12:57:45 -0800 Subject: [PATCH 3/7] Lint --- .../ExportClient/OtlpHttpTraceExportClientTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs index cb774f45f95..82a579577e3 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs @@ -172,7 +172,7 @@ void RunTest(Batch batch) Assert.Contains(resourceSpan.Resource.Attributes, (kvp) => kvp.Key == ResourceSemanticConventions.AttributeServiceNamespace && kvp.Value.StringValue == "ns_1"); } else - { + { Assert.DoesNotContain(resourceSpan.Resource.Attributes, kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName); } } From 9f3d1ef7ff5407c067e7d20b650cce1cffd0168b Mon Sep 17 00:00:00 2001 From: Rajkumar Rangaraj Date: Mon, 9 Dec 2024 14:33:59 -0800 Subject: [PATCH 4/7] Lint --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index b108853de4c..dc0b0b4297e 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -14,7 +14,8 @@ Notes](../../RELEASENOTES.md). * `Grpc.Net.Client` * `Grpc.Tools` - These changes were made to streamline dependencies and reduce the footprint of the exporter. + These changes were made to streamline dependencies and reduce the footprint of + the exporter. ([#6015](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6015)) * Switched from using the `Google.Protobuf` library for serialization to a From ca03dd2066c97b9b7b5565231a358e1a6c76ac86 Mon Sep 17 00:00:00 2001 From: Rajkumar Rangaraj Date: Tue, 10 Dec 2024 11:03:47 -0800 Subject: [PATCH 5/7] Update changelog pr reference. --- .../CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index dc0b0b4297e..6e9cd6eed0c 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -16,11 +16,11 @@ Notes](../../RELEASENOTES.md). These changes were made to streamline dependencies and reduce the footprint of the exporter. - ([#6015](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6015)) + ([#6005](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6005)) * Switched from using the `Google.Protobuf` library for serialization to a custom manual implementation of protobuf serialization. - ([#6015](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6015)) + ([#6005](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6005)) * Fixed an issue where a `service.name` was added to the resource if it was missing. The exporter now respects the resource data provided by the SDK @@ -32,7 +32,7 @@ Notes](../../RELEASENOTES.md). change ensures that the exporter no longer modifies or assumes the value of peer service attributes, aligning it more closely with OpenTelemetry protocol specifications. - ([#6015](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6015)) + ([#6005](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6005)) ## 1.10.0 From 6d6795804f73ea9ed9d07dc99f5f52b1e41323c7 Mon Sep 17 00:00:00 2001 From: Rajkumar Rangaraj Date: Tue, 10 Dec 2024 12:49:35 -0800 Subject: [PATCH 6/7] Remove Grpc.Tools ref from changelog --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 6e9cd6eed0c..d2b643ddbea 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -12,7 +12,6 @@ Notes](../../RELEASENOTES.md). * `Google.Protobuf` * `Grpc` * `Grpc.Net.Client` - * `Grpc.Tools` These changes were made to streamline dependencies and reduce the footprint of the exporter. From 3130b18fd9d38a49df8894a56b1f166c34d6fd8d Mon Sep 17 00:00:00 2001 From: Rajkumar Rangaraj Date: Tue, 10 Dec 2024 13:06:13 -0800 Subject: [PATCH 7/7] test fix --- .../OtlpMetricsExporterTests.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs index f9a68d4e781..78c2d033383 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs @@ -943,9 +943,6 @@ public void MetricsSerialization_ExpandsBufferForMetricsAndSerializes() Assert.Single(request.ResourceMetrics); var resourceMetric = request.ResourceMetrics.First(); - var otlpResource = resourceMetric.Resource; - - Assert.Contains(otlpResource.Attributes, (kvp) => kvp.Key == ResourceSemanticConventions.AttributeServiceName && kvp.Value.ToString().Contains("unknown_service:")); Assert.Single(resourceMetric.ScopeMetrics); var instrumentationLibraryMetrics = resourceMetric.ScopeMetrics.First();