Skip to content

Commit

Permalink
Fix bagage key lowercasing (#3151)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjvankampen authored Feb 2, 2023
1 parent 2e14fe1 commit 4286d63
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#3128](https://github.com/open-telemetry/opentelemetry-python/pull/3128))
- Fix validation of baggage values
([#3058](https://github.com/open-telemetry/opentelemetry-python/pull/3058))
- Fix capitalization of baggage keys
([#3151](https://github.com/open-telemetry/opentelemetry-python/pull/3151))

## Version 1.15.0/0.36b0 (2022-12-09)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def extract(
_logger.warning("Invalid baggage entry: `%s`", entry)
continue

name = unquote_plus(name).strip().lower()
name = unquote_plus(name).strip()
value = unquote_plus(value).strip()

context = set_baggage(
Expand Down
39 changes: 39 additions & 0 deletions opentelemetry-api/tests/baggage/propagation/test_propagation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# type: ignore

from unittest import TestCase

from opentelemetry.baggage import get_baggage, set_baggage
from opentelemetry.baggage.propagation import W3CBaggagePropagator


class TestBaggageManager(TestCase):
def test_propagate_baggage(self):
carrier = {}
propagator = W3CBaggagePropagator()

ctx = set_baggage("Test1", "value1")
ctx = set_baggage("test2", "value2", context=ctx)

propagator.inject(carrier, ctx)
ctx_propagated = propagator.extract(carrier)

self.assertEqual(
get_baggage("Test1", context=ctx_propagated), "value1"
)
self.assertEqual(
get_baggage("test2", context=ctx_propagated), "value2"
)

0 comments on commit 4286d63

Please sign in to comment.