Skip to content

Commit

Permalink
update baggage propagation header (#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
alrex authored Oct 2, 2020
1 parent 308a1a9 commit 14fad78
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 2 additions & 0 deletions opentelemetry-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
([#1118](https://github.com/open-telemetry/opentelemetry-python/pull/1118))
- Allow for Custom Trace and Span IDs Generation - `IdsGenerator` for TracerProvider
([#1153](https://github.com/open-telemetry/opentelemetry-python/pull/1153))
- Update baggage propagation header
([#1194](https://github.com/open-telemetry/opentelemetry-python/pull/1194))

## Version 0.13b0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class BaggagePropagator(textmap.TextMapPropagator):
MAX_HEADER_LENGTH = 8192
MAX_PAIR_LENGTH = 4096
MAX_PAIRS = 180
_BAGGAGE_HEADER_NAME = "otcorrelations"
_BAGGAGE_HEADER_NAME = "baggage"

def extract(
self,
Expand Down Expand Up @@ -85,9 +85,7 @@ def inject(
return

baggage_string = _format_baggage(baggage_entries)
set_in_carrier(
carrier, self._BAGGAGE_HEADER_NAME, baggage_string,
)
set_in_carrier(carrier, self._BAGGAGE_HEADER_NAME, baggage_string)


def _format_baggage(baggage_entries: typing.Mapping[str, object]) -> str:
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-api/tests/baggage/test_baggage_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setUp(self):

def _extract(self, header_value):
"""Test helper"""
header = {"otcorrelations": [header_value]}
header = {"baggage": [header_value]}
return baggage.get_all(self.propagator.extract(get_as_list, header))

def _inject(self, values):
Expand All @@ -42,7 +42,7 @@ def _inject(self, values):
ctx = baggage.set_baggage(k, v, context=ctx)
output = {}
self.propagator.inject(dict.__setitem__, output, context=ctx)
return output.get("otcorrelations")
return output.get("baggage")

def test_no_context_header(self):
baggage_entries = baggage.get_all(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def get_as_list(


class TestDefaultGlobalPropagator(unittest.TestCase):
"""Test ensures the default global composite propagator works as intended
"""
"""Test ensures the default global composite propagator works as intended"""

TRACE_ID = int("12345678901234567890123456789012", 16) # type:int
SPAN_ID = int("1234567890123456", 16) # type:int
Expand All @@ -41,7 +40,7 @@ def test_propagation(self):
)
tracestate_value = "foo=1,bar=2,baz=3"
headers = {
"otcorrelations": ["key1=val1,key2=val2"],
"baggage": ["key1=val1,key2=val2"],
"traceparent": [traceparent_value],
"tracestate": [tracestate_value],
}
Expand All @@ -61,8 +60,8 @@ def test_propagation(self):
output = {}
inject(dict.__setitem__, output, context=ctx)
self.assertEqual(traceparent_value, output["traceparent"])
self.assertIn("key3=val3", output["otcorrelations"])
self.assertIn("key4=val4", output["otcorrelations"])
self.assertIn("key3=val3", output["baggage"])
self.assertIn("key4=val4", output["baggage"])
self.assertIn("foo=1", output["tracestate"])
self.assertIn("bar=2", output["tracestate"])
self.assertIn("baz=3", output["tracestate"])

0 comments on commit 14fad78

Please sign in to comment.