Skip to content

Commit 75a683e

Browse files
[otlp] Update changelog / Remove OtlpExporter resource modification code (open-telemetry#6015)
Co-authored-by: Mikel Blanchard <[email protected]>
1 parent be82099 commit 75a683e

File tree

6 files changed

+31
-28
lines changed

6 files changed

+31
-28
lines changed

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,32 @@ Notes](../../RELEASENOTES.md).
77

88
## Unreleased
99

10+
* Removed the following package references:
11+
12+
* `Google.Protobuf`
13+
* `Grpc`
14+
* `Grpc.Net.Client`
15+
16+
These changes were made to streamline dependencies and reduce the footprint of
17+
the exporter.
18+
([#6005](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6005))
19+
20+
* Switched from using the `Google.Protobuf` library for serialization to a
21+
custom manual implementation of protobuf serialization.
22+
([#6005](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6005))
23+
24+
* Fixed an issue where a `service.name` was added to the resource if it was
25+
missing. The exporter now respects the resource data provided by the SDK
26+
without modifications.
27+
([#6015](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6015))
28+
29+
* Removed the peer service resolver, which was based on earlier experimental
30+
semantic conventions that are not part of the stable specification. This
31+
change ensures that the exporter no longer modifies or assumes the value of
32+
peer service attributes, aligning it more closely with OpenTelemetry protocol
33+
specifications.
34+
([#6005](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6005))
35+
1036
## 1.10.0
1137

1238
Released 2024-Nov-12

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpResourceSerializer.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ internal static class ProtobufOtlpResourceSerializer
99
{
1010
private const int ReserveSizeForLength = 4;
1111

12-
private static readonly string DefaultServiceName = ResourceBuilder.CreateDefault().Build().Attributes.FirstOrDefault(
13-
kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName).Value as string ?? "unknown_service";
14-
1512
internal static int WriteResource(byte[] buffer, int writePosition, Resource? resource)
1613
{
1714
ProtobufOtlpTagWriter.OtlpTagWriterState otlpTagWriterState = new ProtobufOtlpTagWriter.OtlpTagWriterState
@@ -24,41 +21,24 @@ internal static int WriteResource(byte[] buffer, int writePosition, Resource? re
2421
int resourceLengthPosition = otlpTagWriterState.WritePosition;
2522
otlpTagWriterState.WritePosition += ReserveSizeForLength;
2623

27-
bool isServiceNamePresent = false;
2824
if (resource != null && resource != Resource.Empty)
2925
{
3026
if (resource.Attributes is IReadOnlyList<KeyValuePair<string, object>> resourceAttributesList)
3127
{
3228
for (int i = 0; i < resourceAttributesList.Count; i++)
3329
{
34-
var attribute = resourceAttributesList[i];
35-
if (attribute.Key == ResourceSemanticConventions.AttributeServiceName)
36-
{
37-
isServiceNamePresent = true;
38-
}
39-
40-
ProcessResourceAttribute(ref otlpTagWriterState, attribute);
30+
ProcessResourceAttribute(ref otlpTagWriterState, resourceAttributesList[i]);
4131
}
4232
}
4333
else
4434
{
4535
foreach (var attribute in resource.Attributes)
4636
{
47-
if (attribute.Key == ResourceSemanticConventions.AttributeServiceName)
48-
{
49-
isServiceNamePresent = true;
50-
}
51-
5237
ProcessResourceAttribute(ref otlpTagWriterState, attribute);
5338
}
5439
}
5540
}
5641

57-
if (!isServiceNamePresent)
58-
{
59-
ProcessResourceAttribute(ref otlpTagWriterState, new KeyValuePair<string, object>(ResourceSemanticConventions.AttributeServiceName, DefaultServiceName));
60-
}
61-
6242
var resourceLength = otlpTagWriterState.WritePosition - (resourceLengthPosition + ReserveSizeForLength);
6343
ProtobufSerializer.WriteReservedLength(otlpTagWriterState.Buffer, resourceLengthPosition, resourceLength);
6444

test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void RunTest(Batch<Activity> batch)
173173
}
174174
else
175175
{
176-
Assert.Contains(resourceSpan.Resource.Attributes, (kvp) => kvp.Key == ResourceSemanticConventions.AttributeServiceName && kvp.Value.ToString().Contains("unknown_service:"));
176+
Assert.DoesNotContain(resourceSpan.Resource.Attributes, kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName);
177177
}
178178
}
179179
}

test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public void ToOtlpResourceMetricsTest(bool includeServiceNameInResource)
207207
}
208208
else
209209
{
210-
Assert.Contains(otlpResource.Attributes, (kvp) => kvp.Key == ResourceSemanticConventions.AttributeServiceName && kvp.Value.ToString().Contains("unknown_service:"));
210+
Assert.DoesNotContain(otlpResource.Attributes, kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName);
211211
}
212212

213213
Assert.Single(resourceMetric.ScopeMetrics);
@@ -943,9 +943,6 @@ public void MetricsSerialization_ExpandsBufferForMetricsAndSerializes()
943943

944944
Assert.Single(request.ResourceMetrics);
945945
var resourceMetric = request.ResourceMetrics.First();
946-
var otlpResource = resourceMetric.Resource;
947-
948-
Assert.Contains(otlpResource.Attributes, (kvp) => kvp.Key == ResourceSemanticConventions.AttributeServiceName && kvp.Value.ToString().Contains("unknown_service:"));
949946

950947
Assert.Single(resourceMetric.ScopeMetrics);
951948
var instrumentationLibraryMetrics = resourceMetric.ScopeMetrics.First();

test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpResourceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void ToOtlpResourceTest(bool includeServiceNameInResource)
4343
}
4444
else
4545
{
46-
Assert.Contains(otlpResource.Attributes, (kvp) => kvp.Key == ResourceSemanticConventions.AttributeServiceName && kvp.Value.ToString().Contains("unknown_service:"));
46+
Assert.DoesNotContain(otlpResource.Attributes, kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName);
4747
}
4848
}
4949
}

test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void RunTest(SdkLimitOptions sdkOptions, Batch<Activity> batch)
184184
}
185185
else
186186
{
187-
Assert.Contains(otlpResource.Attributes, (kvp) => kvp.Key == ResourceSemanticConventions.AttributeServiceName && kvp.Value.ToString().Contains("unknown_service:"));
187+
Assert.DoesNotContain(otlpResource.Attributes, kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName);
188188
}
189189

190190
var scopeSpans = request.ResourceSpans.First().ScopeSpans;

0 commit comments

Comments
 (0)