From b14e6b36485bad9efd78eb3061e12356c7c3d800 Mon Sep 17 00:00:00 2001 From: Mateusz Lach Date: Tue, 11 Jun 2024 07:42:50 +0200 Subject: [PATCH 1/3] revert space encoding change --- src/OpenTelemetry.Api/CHANGELOG.md | 3 +++ .../Context/Propagation/BaggagePropagator.cs | 7 ++++--- .../Trace/Propagation/BaggagePropagatorTest.cs | 17 ++++------------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/OpenTelemetry.Api/CHANGELOG.md b/src/OpenTelemetry.Api/CHANGELOG.md index 3139700ac14..7d539384e38 100644 --- a/src/OpenTelemetry.Api/CHANGELOG.md +++ b/src/OpenTelemetry.Api/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* **Breaking change:** Revert space character encoding change from `+` to `%20` + for baggage item values from [#5303](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5303) + ## 1.9.0-rc.1 Released 2024-Jun-07 diff --git a/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs b/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs index e9dc29d950d..57bdb453b8f 100644 --- a/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs +++ b/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs @@ -1,6 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +using System.Net; using System.Text; using OpenTelemetry.Internal; @@ -93,7 +94,7 @@ public override void Inject(PropagationContext context, T carrier, Action> { new KeyValuePair(BaggagePropagator.BaggageHeaderName, initialBaggage), @@ -144,11 +142,11 @@ public void ValidateSpecialCharsBaggageExtraction() Assert.False(propagationContext == default); Assert.True(propagationContext.ActivityContext == default); - Assert.Equal(4, propagationContext.Baggage.Count); + Assert.Equal(3, propagationContext.Baggage.Count); var actualBaggage = propagationContext.Baggage.GetBaggage(); - Assert.Equal(4, actualBaggage.Count); + Assert.Equal(3, actualBaggage.Count); Assert.True(actualBaggage.ContainsKey("key 1")); Assert.Equal("value 1", actualBaggage["key 1"]); @@ -158,10 +156,6 @@ public void ValidateSpecialCharsBaggageExtraction() Assert.True(actualBaggage.ContainsKey("key()3")); Assert.Equal("value()!&;:", actualBaggage["key()3"]); - - // x20-x7E range - Assert.True(actualBaggage.ContainsKey("key4")); - Assert.Equal(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", actualBaggage["key4"]); } [Fact] @@ -201,14 +195,11 @@ public void ValidateSpecialCharsBaggageInjection() { { "key 1", "value 1" }, { "key2", "!x_x,x-x&x(x\");:" }, - - // x20-x7E range - { "key3", " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" }, })); this.baggage.Inject(propagationContext, carrier, Setter); Assert.Single(carrier); - Assert.Equal("key%201=value%201,key2=%21x_x%2Cx-x%26x%28x%22%29%3B%3A,key3=%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~", carrier[BaggagePropagator.BaggageHeaderName]); + Assert.Equal("key+1=value+1,key2=!x_x%2Cx-x%26x(x%22)%3B%3A", carrier[BaggagePropagator.BaggageHeaderName]); } } From e474fa78360f899aba3681697237d3e20f929f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20=C5=81ach?= Date: Tue, 11 Jun 2024 18:56:53 +0200 Subject: [PATCH 2/3] Update src/OpenTelemetry.Api/CHANGELOG.md --- src/OpenTelemetry.Api/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Api/CHANGELOG.md b/src/OpenTelemetry.Api/CHANGELOG.md index 7d539384e38..8e27df3a32e 100644 --- a/src/OpenTelemetry.Api/CHANGELOG.md +++ b/src/OpenTelemetry.Api/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased * **Breaking change:** Revert space character encoding change from `+` to `%20` - for baggage item values from [#5303](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5303) + for baggage item values from [#5303](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5303) [#5687](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5687) ## 1.9.0-rc.1 From 6b04b9bd94e3d1cabbe77bd78b404f8cc95d1670 Mon Sep 17 00:00:00 2001 From: Mateusz Lach Date: Tue, 11 Jun 2024 18:59:52 +0200 Subject: [PATCH 3/3] changelog formatting fix --- src/OpenTelemetry.Api/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Api/CHANGELOG.md b/src/OpenTelemetry.Api/CHANGELOG.md index 8e27df3a32e..5394fdf705e 100644 --- a/src/OpenTelemetry.Api/CHANGELOG.md +++ b/src/OpenTelemetry.Api/CHANGELOG.md @@ -3,7 +3,8 @@ ## Unreleased * **Breaking change:** Revert space character encoding change from `+` to `%20` - for baggage item values from [#5303](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5303) [#5687](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5687) + for baggage item values from [#5303](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5303) + ([#5687](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5687)) ## 1.9.0-rc.1