Skip to content

Commit 7065739

Browse files
authored
[Exporter.Zipkin] Use new attributes to propagate scope (#5473)
1 parent 49f16e4 commit 7065739

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
* Zipkin tags used for Instrumentation Library changed from `otel.library.name` and
6+
`otel.library.version` to `otel.scope.name` and `otel.scope.version` respectively.
7+
Old versions of attributes are deprecated, but still exported
8+
for [backward compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.31.0/specification/common/mapping-to-non-otlp.md#instrumentationscope).
9+
([#5473](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5473))
10+
511
## 1.8.0-beta.1
612

713
Released 2024-Mar-14

src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinActivityConversionExtensions.cs

+6
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,15 @@ internal static ZipkinSpan ToZipkinSpan(this Activity activity, ZipkinEndpoint l
8787
var activitySource = activity.Source;
8888
if (!string.IsNullOrEmpty(activitySource.Name))
8989
{
90+
PooledList<KeyValuePair<string, object>>.Add(ref tagState.Tags, new KeyValuePair<string, object>("otel.scope.name", activitySource.Name));
91+
92+
// otel.library.name is deprecated, but has to be propagated according to https://github.com/open-telemetry/opentelemetry-specification/blob/v1.31.0/specification/common/mapping-to-non-otlp.md#instrumentationscope
9093
PooledList<KeyValuePair<string, object>>.Add(ref tagState.Tags, new KeyValuePair<string, object>("otel.library.name", activitySource.Name));
9194
if (!string.IsNullOrEmpty(activitySource.Version))
9295
{
96+
PooledList<KeyValuePair<string, object>>.Add(ref tagState.Tags, new KeyValuePair<string, object>("otel.scope.version", activitySource.Version));
97+
98+
// otel.library.version is deprecated, but has to be propagated according to https://github.com/open-telemetry/opentelemetry-specification/blob/v1.31.0/specification/common/mapping-to-non-otlp.md#instrumentationscope
9399
PooledList<KeyValuePair<string, object>>.Add(ref tagState.Tags, new KeyValuePair<string, object>("otel.library.version", activitySource.Version));
94100
}
95101
}

test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ public void IntegrationTest(
422422
}
423423

424424
Assert.Equal(
425-
$@"[{{""traceId"":""{traceId}"",""name"":""Name"",{parentId}""id"":""{ZipkinActivityConversionExtensions.EncodeSpanId(context.SpanId)}"",""kind"":""CLIENT"",""timestamp"":{timestamp},""duration"":60000000,""localEndpoint"":{{""serviceName"":""{serviceName}""{ipInformation}}},""remoteEndpoint"":{{""serviceName"":""http://localhost:44312/""}},""annotations"":[{{""timestamp"":{eventTimestamp},""value"":""Event1""}},{{""timestamp"":{eventTimestamp},""value"":""Event2""}}],""tags"":{{{resourceTags}""stringKey"":""value"",""longKey"":""1"",""longKey2"":""1"",""doubleKey"":""1"",""doubleKey2"":""1"",""longArrayKey"":""[1,2]"",""boolKey"":""true"",""boolArrayKey"":""[true,false]"",""http.host"":""http://localhost:44312/"",{statusTag}{errorTag}""otel.library.name"":""CreateTestActivity"",""peer.service"":""http://localhost:44312/""}}}}]",
425+
$@"[{{""traceId"":""{traceId}"",""name"":""Name"",{parentId}""id"":""{ZipkinActivityConversionExtensions.EncodeSpanId(context.SpanId)}"",""kind"":""CLIENT"",""timestamp"":{timestamp},""duration"":60000000,""localEndpoint"":{{""serviceName"":""{serviceName}""{ipInformation}}},""remoteEndpoint"":{{""serviceName"":""http://localhost:44312/""}},""annotations"":[{{""timestamp"":{eventTimestamp},""value"":""Event1""}},{{""timestamp"":{eventTimestamp},""value"":""Event2""}}],""tags"":{{{resourceTags}""stringKey"":""value"",""longKey"":""1"",""longKey2"":""1"",""doubleKey"":""1"",""doubleKey2"":""1"",""longArrayKey"":""[1,2]"",""boolKey"":""true"",""boolArrayKey"":""[true,false]"",""http.host"":""http://localhost:44312/"",{statusTag}{errorTag}""otel.scope.name"":""CreateTestActivity"",""otel.library.name"":""CreateTestActivity"",""peer.service"":""http://localhost:44312/""}}}}]",
426426
Responses[requestId]);
427427
}
428428

0 commit comments

Comments
 (0)