Skip to content

Commit

Permalink
rename BaggagePropagator to W3CBaggagePropagator (#1663)
Browse files Browse the repository at this point in the history
Co-authored-by: Leighton Chen <[email protected]>
  • Loading branch information
alrex and lzchen authored Mar 3, 2021
1 parent a046518 commit 9bf28fb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Moving `Getter`, `Setter` and `TextMapPropagator` out of `opentelemetry.trace.propagation` and
into `opentelemetry.propagators`
([#1662])(https://github.com/open-telemetry/opentelemetry-python/pull/1662)
- Rename `BaggagePropagator` to `W3CBaggagePropagator`
([#1663])(https://github.com/open-telemetry/opentelemetry-python/pull/1663)

## [0.18b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.18b0) - 2021-02-16

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ opentelemetry_tracer_provider =
default_tracer_provider = opentelemetry.trace:DefaultTracerProvider
opentelemetry_propagator =
tracecontext = opentelemetry.trace.propagation.tracecontext:TraceContextTextMapPropagator
baggage = opentelemetry.baggage.propagation:BaggagePropagator
baggage = opentelemetry.baggage.propagation:W3CBaggagePropagator

[options.extras_require]
test =
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from opentelemetry.propagators import textmap


class BaggagePropagator(textmap.TextMapPropagator):
class W3CBaggagePropagator(textmap.TextMapPropagator):
"""Extracts and injects Baggage which is used to annotate telemetry."""

MAX_HEADER_LENGTH = 8192
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/src/opentelemetry/propagate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
``opentelemetry.propagators.composite.CompositeHTTPPropagator`` with 2
propagators, one of type
``opentelemetry.trace.propagation.tracecontext.TraceContextTextMapPropagator``
and other of type ``opentelemetry.baggage.propagation.BaggagePropagator``.
and other of type ``opentelemetry.baggage.propagation.W3CBaggagePropagator``.
Notice that these propagator classes are defined as
``opentelemetry_propagator`` entry points in the ``setup.cfg`` file of
``opentelemetry``.
Expand Down
12 changes: 6 additions & 6 deletions opentelemetry-api/tests/baggage/test_baggage_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from unittest.mock import Mock, patch

from opentelemetry import baggage
from opentelemetry.baggage.propagation import BaggagePropagator
from opentelemetry.baggage.propagation import W3CBaggagePropagator
from opentelemetry.context import get_current
from opentelemetry.propagators.textmap import DictGetter

Expand All @@ -25,7 +25,7 @@

class TestBaggagePropagation(unittest.TestCase):
def setUp(self):
self.propagator = BaggagePropagator()
self.propagator = W3CBaggagePropagator()

def _extract(self, header_value):
"""Test helper"""
Expand Down Expand Up @@ -87,7 +87,7 @@ def test_invalid_header(self):
self.assertEqual(self._extract(header), expected)

def test_header_too_long(self):
long_value = "s" * (BaggagePropagator.MAX_HEADER_LENGTH + 1)
long_value = "s" * (W3CBaggagePropagator.MAX_HEADER_LENGTH + 1)
header = "key1={}".format(long_value)
expected = {}
self.assertEqual(self._extract(header), expected)
Expand All @@ -96,15 +96,15 @@ def test_header_contains_too_many_entries(self):
header = ",".join(
[
"key{}=val".format(k)
for k in range(BaggagePropagator.MAX_PAIRS + 1)
for k in range(W3CBaggagePropagator.MAX_PAIRS + 1)
]
)
self.assertEqual(
len(self._extract(header)), BaggagePropagator.MAX_PAIRS
len(self._extract(header)), W3CBaggagePropagator.MAX_PAIRS
)

def test_header_contains_pair_too_long(self):
long_value = "s" * (BaggagePropagator.MAX_PAIR_LENGTH + 1)
long_value = "s" * (W3CBaggagePropagator.MAX_PAIR_LENGTH + 1)
header = "key1=value1,key2={},key3=value3".format(long_value)
expected = {"key1": "value1", "key3": "value3"}
self.assertEqual(self._extract(header), expected)
Expand Down
5 changes: 3 additions & 2 deletions opentelemetry-api/tests/propagators/test_propagators.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from unittest import TestCase
from unittest.mock import Mock, patch

from opentelemetry.baggage.propagation import BaggagePropagator
from opentelemetry.baggage.propagation import W3CBaggagePropagator
from opentelemetry.environment_variables import OTEL_PROPAGATORS
from opentelemetry.trace.propagation.tracecontext import (
TraceContextTextMapPropagator,
Expand All @@ -33,7 +33,8 @@ def test_propagators(propagators):

self.assertEqual(len(propagators), 2)
self.assertEqual(
propagators, {TraceContextTextMapPropagator, BaggagePropagator}
propagators,
{TraceContextTextMapPropagator, W3CBaggagePropagator},
)

mock_compositehttppropagator.configure_mock(
Expand Down

0 comments on commit 9bf28fb

Please sign in to comment.