diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index d8f52e54309..d2b643ddbea 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -7,6 +7,32 @@ Notes](../../RELEASENOTES.md). ## Unreleased +* Removed the following package references: + + * `Google.Protobuf` + * `Grpc` + * `Grpc.Net.Client` + + These changes were made to streamline dependencies and reduce the footprint of + the exporter. + ([#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. + ([#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 + 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. + ([#6005](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6005)) + ## 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 cf5833e376d..620c2a0b187 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs @@ -173,7 +173,7 @@ void RunTest(Batch batch) } 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 40c075c44a3..78c2d033383 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); @@ -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(); 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 ab3a1c0d3e2..e96b5d43f44 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;