Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bagage key lowercasing #3151

Merged
merged 6 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
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
37 changes: 37 additions & 0 deletions opentelemetry-api/tests/baggage/propagation/test_propagation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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.

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"
)