Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@ 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.
([#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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<KeyValuePair<string, object>> 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<string, object>(ResourceSemanticConventions.AttributeServiceName, DefaultServiceName));
}

var resourceLength = otlpTagWriterState.WritePosition - (resourceLengthPosition + ReserveSizeForLength);
ProtobufSerializer.WriteReservedLength(otlpTagWriterState.Buffer, resourceLengthPosition, resourceLength);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void RunTest(Batch<Activity> 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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void RunTest(SdkLimitOptions sdkOptions, Batch<Activity> 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;
Expand Down