From fbd29b2b333b377c9f62ab4417215751e9b9bc2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Tue, 26 Mar 2024 08:15:23 +0100 Subject: [PATCH 1/3] [Exporter.Zipkin] Use new attributes to propagate scope --- src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md | 6 ++++++ .../Implementation/ZipkinActivityConversionExtensions.cs | 6 ++++++ .../ZipkinExporterTests.cs | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md index 4ef269a7c61..ff167cd3950 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +* Zipkin tags used for InstrumentationLibrary changed from `otel.library.name`, + `otel.library.version` to `otel.scope.name`, `otel.scope.version` respectively. + Old versions of attributes are deprecated, but still available + for [backward compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.31.0/specification/common/mapping-to-non-otlp.md#instrumentationscope). + ([#5473](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5473)) + ## 1.8.0-beta.1 Released 2024-Mar-14 diff --git a/src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinActivityConversionExtensions.cs b/src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinActivityConversionExtensions.cs index 768d308659d..802591d052a 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinActivityConversionExtensions.cs +++ b/src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinActivityConversionExtensions.cs @@ -87,9 +87,15 @@ internal static ZipkinSpan ToZipkinSpan(this Activity activity, ZipkinEndpoint l var activitySource = activity.Source; if (!string.IsNullOrEmpty(activitySource.Name)) { + PooledList>.Add(ref tagState.Tags, new KeyValuePair("otel.scope.name", activitySource.Name)); + + // 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 PooledList>.Add(ref tagState.Tags, new KeyValuePair("otel.library.name", activitySource.Name)); if (!string.IsNullOrEmpty(activitySource.Version)) { + PooledList>.Add(ref tagState.Tags, new KeyValuePair("otel.scope.version", activitySource.Version)); + + // 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 PooledList>.Add(ref tagState.Tags, new KeyValuePair("otel.library.version", activitySource.Version)); } } diff --git a/test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs b/test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs index 9ed6a4d3dfc..308f2e6715a 100644 --- a/test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs @@ -422,7 +422,7 @@ public void IntegrationTest( } Assert.Equal( - $@"[{{""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/""}}}}]", + $@"[{{""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/""}}}}]", Responses[requestId]); } From cee1a25968342f99d74e58852c4ba52f998112ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Tue, 26 Mar 2024 18:05:49 +0100 Subject: [PATCH 2/3] Update src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md Co-authored-by: Mikel Blanchard --- src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md index ff167cd3950..6512672c29b 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* Zipkin tags used for InstrumentationLibrary changed from `otel.library.name`, - `otel.library.version` to `otel.scope.name`, `otel.scope.version` respectively. +* Zipkin tags used for InstrumentationLibrary changed from `otel.library.name` and + `otel.library.version` to `otel.scope.name` and `otel.scope.version` respectively. Old versions of attributes are deprecated, but still available for [backward compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.31.0/specification/common/mapping-to-non-otlp.md#instrumentationscope). ([#5473](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5473)) From f9523f5765aa0ee0f9e07d37c0621a694ddb8805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Tue, 26 Mar 2024 18:14:14 +0100 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Vishwesh Bankwar --- src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md index 6512672c29b..c515bac5b7a 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md @@ -2,9 +2,9 @@ ## Unreleased -* Zipkin tags used for InstrumentationLibrary changed from `otel.library.name` and +* Zipkin tags used for Instrumentation Library changed from `otel.library.name` and `otel.library.version` to `otel.scope.name` and `otel.scope.version` respectively. - Old versions of attributes are deprecated, but still available + Old versions of attributes are deprecated, but still exported for [backward compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.31.0/specification/common/mapping-to-non-otlp.md#instrumentationscope). ([#5473](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5473))