diff --git a/docs/api/api.rst b/docs/api/api.rst index e1e82114296..ec6d8b03aa3 100644 --- a/docs/api/api.rst +++ b/docs/api/api.rst @@ -6,8 +6,8 @@ OpenTelemetry Python API .. toctree:: :maxdepth: 1 + baggage configuration context - correlationcontext metrics trace diff --git a/docs/api/baggage.propagation.rst b/docs/api/baggage.propagation.rst new file mode 100644 index 00000000000..7c8eba79407 --- /dev/null +++ b/docs/api/baggage.propagation.rst @@ -0,0 +1,7 @@ +opentelemetry.baggage.propagation package +==================================================== + +Module contents +--------------- + +.. automodule:: opentelemetry.baggage.propagation diff --git a/docs/api/baggage.rst b/docs/api/baggage.rst new file mode 100644 index 00000000000..34712e78bd8 --- /dev/null +++ b/docs/api/baggage.rst @@ -0,0 +1,14 @@ +opentelemetry.baggage package +======================================== + +Subpackages +----------- + +.. toctree:: + + baggage.propagation + +Module contents +--------------- + +.. automodule:: opentelemetry.baggage diff --git a/docs/api/correlationcontext.propagation.rst b/docs/api/correlationcontext.propagation.rst deleted file mode 100644 index a9b94aa4fb4..00000000000 --- a/docs/api/correlationcontext.propagation.rst +++ /dev/null @@ -1,7 +0,0 @@ -opentelemetry.correlationcontext.propagation package -==================================================== - -Module contents ---------------- - -.. automodule:: opentelemetry.correlationcontext.propagation diff --git a/docs/api/correlationcontext.rst b/docs/api/correlationcontext.rst deleted file mode 100644 index 10e7b2e573b..00000000000 --- a/docs/api/correlationcontext.rst +++ /dev/null @@ -1,14 +0,0 @@ -opentelemetry.correlationcontext package -======================================== - -Subpackages ------------ - -.. toctree:: - - correlationcontext.propagation - -Module contents ---------------- - -.. automodule:: opentelemetry.correlationcontext diff --git a/docs/getting-started.rst b/docs/getting-started.rst index 8c27ddfa4d3..4d643eca629 100644 --- a/docs/getting-started.rst +++ b/docs/getting-started.rst @@ -174,7 +174,7 @@ Now run the above script, hit the root url (http://localhost:5000/) a few times, python flask_example.py -Configure Your HTTP Propagator (b3, CorrelationContext) +Configure Your HTTP Propagator (b3, Baggage) ------------------------------------------------------- A major feature of distributed tracing is the ability to correlate a trace across diff --git a/instrumentation/opentelemetry-instrumentation-opentracing-shim/src/opentelemetry/instrumentation/opentracing_shim/__init__.py b/instrumentation/opentelemetry-instrumentation-opentracing-shim/src/opentelemetry/instrumentation/opentracing_shim/__init__.py index 90d7f0a30cb..78672444bd5 100644 --- a/instrumentation/opentelemetry-instrumentation-opentracing-shim/src/opentelemetry/instrumentation/opentracing_shim/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-opentracing-shim/src/opentelemetry/instrumentation/opentracing_shim/__init__.py @@ -100,8 +100,8 @@ ) from opentelemetry import propagators +from opentelemetry.baggage import get_baggage, set_baggage from opentelemetry.context import Context, attach, detach, get_value, set_value -from opentelemetry.correlationcontext import get_correlation, set_correlation from opentelemetry.instrumentation.opentracing_shim import util from opentelemetry.instrumentation.opentracing_shim.version import __version__ from opentelemetry.trace import INVALID_SPAN_CONTEXT, DefaultSpan, Link @@ -290,7 +290,7 @@ def set_baggage_item(self, key: str, value: str): value: A tag value. """ # pylint: disable=protected-access - self._context._baggage = set_correlation( + self._context._baggage = set_baggage( key, value, context=self._context._baggage ) @@ -303,7 +303,7 @@ def get_baggage_item(self, key: str) -> Optional[object]: Returns this :class:`SpanShim` instance to allow call chaining. """ # pylint: disable=protected-access - return get_correlation(key, context=self._context._baggage) + return get_baggage(key, context=self._context._baggage) class ScopeShim(Scope): diff --git a/opentelemetry-api/CHANGELOG.md b/opentelemetry-api/CHANGELOG.md index a22f98585ec..5ee9d96e975 100644 --- a/opentelemetry-api/CHANGELOG.md +++ b/opentelemetry-api/CHANGELOG.md @@ -12,6 +12,8 @@ ([#1034](https://github.com/open-telemetry/opentelemetry-python/pull/1034)) - Remove lazy Event and Link API from Span interface ([#1045](https://github.com/open-telemetry/opentelemetry-python/pull/1045)) +- Rename CorrelationContext to Baggage + ([#1060](https://github.com/open-telemetry/opentelemetry-python/pull/1060)) ## Version 0.12b0 diff --git a/opentelemetry-api/src/opentelemetry/correlationcontext/__init__.py b/opentelemetry-api/src/opentelemetry/baggage/__init__.py similarity index 63% rename from opentelemetry-api/src/opentelemetry/correlationcontext/__init__.py rename to opentelemetry-api/src/opentelemetry/baggage/__init__.py index 8dbb357495a..cdb2196f741 100644 --- a/opentelemetry-api/src/opentelemetry/correlationcontext/__init__.py +++ b/opentelemetry-api/src/opentelemetry/baggage/__init__.py @@ -18,31 +18,31 @@ from opentelemetry.context import get_value, set_value from opentelemetry.context.context import Context -_CORRELATION_CONTEXT_KEY = "correlation-context" +_BAGGAGE_KEY = "baggage" -def get_correlations( +def get_all( context: typing.Optional[Context] = None, ) -> typing.Mapping[str, object]: - """Returns the name/value pairs in the CorrelationContext + """Returns the name/value pairs in the Baggage Args: context: The Context to use. If not set, uses current Context Returns: - Name/value pairs in the CorrelationContext + The name/value pairs in the Baggage """ - correlations = get_value(_CORRELATION_CONTEXT_KEY, context=context) - if isinstance(correlations, dict): - return MappingProxyType(correlations.copy()) + baggage = get_value(_BAGGAGE_KEY, context=context) + if isinstance(baggage, dict): + return MappingProxyType(baggage.copy()) return MappingProxyType({}) -def get_correlation( +def get_baggage( name: str, context: typing.Optional[Context] = None ) -> typing.Optional[object]: """Provides access to the value for a name/value pair in the - CorrelationContext + Baggage Args: name: The name of the value to retrieve @@ -52,13 +52,13 @@ def get_correlation( The value associated with the given name, or null if the given name is not present. """ - return get_correlations(context=context).get(name) + return get_all(context=context).get(name) -def set_correlation( +def set_baggage( name: str, value: object, context: typing.Optional[Context] = None ) -> Context: - """Sets a value in the CorrelationContext + """Sets a value in the Baggage Args: name: The name of the value to set @@ -68,15 +68,15 @@ def set_correlation( Returns: A Context with the value updated """ - correlations = dict(get_correlations(context=context)) - correlations[name] = value - return set_value(_CORRELATION_CONTEXT_KEY, correlations, context=context) + baggage = dict(get_all(context=context)) + baggage[name] = value + return set_value(_BAGGAGE_KEY, baggage, context=context) -def remove_correlation( +def remove_baggage( name: str, context: typing.Optional[Context] = None ) -> Context: - """Removes a value from the CorrelationContext + """Removes a value from the Baggage Args: name: The name of the value to remove @@ -85,19 +85,19 @@ def remove_correlation( Returns: A Context with the name/value removed """ - correlations = dict(get_correlations(context=context)) - correlations.pop(name, None) + baggage = dict(get_all(context=context)) + baggage.pop(name, None) - return set_value(_CORRELATION_CONTEXT_KEY, correlations, context=context) + return set_value(_BAGGAGE_KEY, baggage, context=context) -def clear_correlations(context: typing.Optional[Context] = None) -> Context: - """Removes all values from the CorrelationContext +def clear(context: typing.Optional[Context] = None) -> Context: + """Removes all values from the Baggage Args: context: The Context to use. If not set, uses current Context Returns: - A Context with all correlations removed + A Context with all baggage entries removed """ - return set_value(_CORRELATION_CONTEXT_KEY, {}, context=context) + return set_value(_BAGGAGE_KEY, {}, context=context) diff --git a/opentelemetry-api/src/opentelemetry/correlationcontext/propagation/__init__.py b/opentelemetry-api/src/opentelemetry/baggage/propagation/__init__.py similarity index 68% rename from opentelemetry-api/src/opentelemetry/correlationcontext/propagation/__init__.py rename to opentelemetry-api/src/opentelemetry/baggage/propagation/__init__.py index 4032394ce71..4d0009892ad 100644 --- a/opentelemetry-api/src/opentelemetry/correlationcontext/propagation/__init__.py +++ b/opentelemetry-api/src/opentelemetry/baggage/propagation/__init__.py @@ -15,17 +15,17 @@ import typing import urllib.parse -from opentelemetry import correlationcontext +from opentelemetry import baggage from opentelemetry.context import get_current from opentelemetry.context.context import Context from opentelemetry.trace.propagation import httptextformat -class CorrelationContextPropagator(httptextformat.HTTPTextFormat): +class BaggagePropagator(httptextformat.HTTPTextFormat): MAX_HEADER_LENGTH = 8192 MAX_PAIR_LENGTH = 4096 MAX_PAIRS = 180 - _CORRELATION_CONTEXT_HEADER_NAME = "otcorrelationcontext" + _BAGGAGE_HEADER_NAME = "otcorrelations" def extract( self, @@ -35,7 +35,7 @@ def extract( carrier: httptextformat.HTTPTextFormatT, context: typing.Optional[Context] = None, ) -> Context: - """Extract CorrelationContext from the carrier. + """Extract Baggage from the carrier. See `opentelemetry.trace.propagation.httptextformat.HTTPTextFormat.extract` @@ -45,25 +45,25 @@ def extract( context = get_current() header = _extract_first_element( - get_from_carrier(carrier, self._CORRELATION_CONTEXT_HEADER_NAME) + get_from_carrier(carrier, self._BAGGAGE_HEADER_NAME) ) if not header or len(header) > self.MAX_HEADER_LENGTH: return context - correlations = header.split(",") - total_correlations = self.MAX_PAIRS - for correlation in correlations: - if total_correlations <= 0: + baggage_entries = header.split(",") + total_baggage_entries = self.MAX_PAIRS + for entry in baggage_entries: + if total_baggage_entries <= 0: return context - total_correlations -= 1 - if len(correlation) > self.MAX_PAIR_LENGTH: + total_baggage_entries -= 1 + if len(entry) > self.MAX_PAIR_LENGTH: continue try: - name, value = correlation.split("=", 1) + name, value = entry.split("=", 1) except Exception: # pylint: disable=broad-except continue - context = correlationcontext.set_correlation( + context = baggage.set_baggage( urllib.parse.unquote(name).strip(), urllib.parse.unquote(value).strip(), context=context, @@ -77,27 +77,25 @@ def inject( carrier: httptextformat.HTTPTextFormatT, context: typing.Optional[Context] = None, ) -> None: - """Injects CorrelationContext into the carrier. + """Injects Baggage into the carrier. See `opentelemetry.trace.propagation.httptextformat.HTTPTextFormat.inject` """ - correlations = correlationcontext.get_correlations(context=context) - if not correlations: + baggage_entries = baggage.get_all(context=context) + if not baggage_entries: return - correlation_context_string = _format_correlations(correlations) + baggage_string = _format_baggage(baggage_entries) set_in_carrier( - carrier, - self._CORRELATION_CONTEXT_HEADER_NAME, - correlation_context_string, + carrier, self._BAGGAGE_HEADER_NAME, baggage_string, ) -def _format_correlations(correlations: typing.Mapping[str, object]) -> str: +def _format_baggage(baggage_entries: typing.Mapping[str, object]) -> str: return ",".join( key + "=" + urllib.parse.quote_plus(str(value)) - for key, value in correlations.items() + for key, value in baggage_entries.items() ) diff --git a/opentelemetry-api/src/opentelemetry/propagators/__init__.py b/opentelemetry-api/src/opentelemetry/propagators/__init__.py index 5aa53e25dce..8f5a38df76f 100644 --- a/opentelemetry-api/src/opentelemetry/propagators/__init__.py +++ b/opentelemetry-api/src/opentelemetry/propagators/__init__.py @@ -55,12 +55,8 @@ def example_route(): import typing -import opentelemetry.trace as trace -from opentelemetry.context import get_current +from opentelemetry.baggage.propagation import BaggagePropagator from opentelemetry.context.context import Context -from opentelemetry.correlationcontext.propagation import ( - CorrelationContextPropagator, -) from opentelemetry.propagators import composite from opentelemetry.trace.propagation import httptextformat from opentelemetry.trace.propagation.tracecontexthttptextformat import ( @@ -111,7 +107,7 @@ def inject( _HTTP_TEXT_FORMAT = composite.CompositeHTTPPropagator( - [TraceContextHTTPTextFormat(), CorrelationContextPropagator()], + [TraceContextHTTPTextFormat(), BaggagePropagator()], ) # type: httptextformat.HTTPTextFormat diff --git a/opentelemetry-api/tests/correlationcontext/test_baggage.py b/opentelemetry-api/tests/correlationcontext/test_baggage.py new file mode 100644 index 00000000000..276d2bc8b0a --- /dev/null +++ b/opentelemetry-api/tests/correlationcontext/test_baggage.py @@ -0,0 +1,69 @@ +# 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. + +import unittest + +from opentelemetry import baggage, context + + +class TestBaggageManager(unittest.TestCase): + def test_set_baggage(self): + self.assertEqual({}, baggage.get_all()) + + ctx = baggage.set_baggage("test", "value") + self.assertEqual(baggage.get_baggage("test", context=ctx), "value") + + ctx = baggage.set_baggage("test", "value2", context=ctx) + self.assertEqual(baggage.get_baggage("test", context=ctx), "value2") + + def test_baggages_current_context(self): + token = context.attach(baggage.set_baggage("test", "value")) + self.assertEqual(baggage.get_baggage("test"), "value") + context.detach(token) + self.assertEqual(baggage.get_baggage("test"), None) + + def test_set_multiple_baggage_entries(self): + ctx = baggage.set_baggage("test", "value") + ctx = baggage.set_baggage("test2", "value2", context=ctx) + self.assertEqual(baggage.get_baggage("test", context=ctx), "value") + self.assertEqual(baggage.get_baggage("test2", context=ctx), "value2") + self.assertEqual( + baggage.get_all(context=ctx), {"test": "value", "test2": "value2"}, + ) + + def test_modifying_baggage(self): + ctx = baggage.set_baggage("test", "value") + self.assertEqual(baggage.get_baggage("test", context=ctx), "value") + baggage_entries = baggage.get_all(context=ctx) + with self.assertRaises(TypeError): + baggage_entries["test"] = "mess-this-up" + self.assertEqual(baggage.get_baggage("test", context=ctx), "value") + + def test_remove_baggage_entry(self): + self.assertEqual({}, baggage.get_all()) + + ctx = baggage.set_baggage("test", "value") + ctx = baggage.set_baggage("test2", "value2", context=ctx) + ctx = baggage.remove_baggage("test", context=ctx) + self.assertEqual(baggage.get_baggage("test", context=ctx), None) + self.assertEqual(baggage.get_baggage("test2", context=ctx), "value2") + + def test_clear_baggage(self): + self.assertEqual({}, baggage.get_all()) + + ctx = baggage.set_baggage("test", "value") + self.assertEqual(baggage.get_baggage("test", context=ctx), "value") + + ctx = baggage.clear(context=ctx) + self.assertEqual(baggage.get_all(context=ctx), {}) diff --git a/opentelemetry-api/tests/correlationcontext/test_correlation_context_propagation.py b/opentelemetry-api/tests/correlationcontext/test_baggage_propagation.py similarity index 80% rename from opentelemetry-api/tests/correlationcontext/test_correlation_context_propagation.py rename to opentelemetry-api/tests/correlationcontext/test_baggage_propagation.py index c33326b173c..e8bd45d0656 100644 --- a/opentelemetry-api/tests/correlationcontext/test_correlation_context_propagation.py +++ b/opentelemetry-api/tests/correlationcontext/test_baggage_propagation.py @@ -15,11 +15,9 @@ import typing import unittest -from opentelemetry import correlationcontext +from opentelemetry import baggage +from opentelemetry.baggage.propagation import BaggagePropagator from opentelemetry.context import get_current -from opentelemetry.correlationcontext.propagation import ( - CorrelationContextPropagator, -) def get_as_list( @@ -28,31 +26,29 @@ def get_as_list( return dict_object.get(key, []) -class TestCorrelationContextPropagation(unittest.TestCase): +class TestBaggagePropagation(unittest.TestCase): def setUp(self): - self.propagator = CorrelationContextPropagator() + self.propagator = BaggagePropagator() def _extract(self, header_value): """Test helper""" - header = {"otcorrelationcontext": [header_value]} - return correlationcontext.get_correlations( - self.propagator.extract(get_as_list, header) - ) + header = {"otcorrelations": [header_value]} + return baggage.get_all(self.propagator.extract(get_as_list, header)) def _inject(self, values): """Test helper""" ctx = get_current() for k, v in values.items(): - ctx = correlationcontext.set_correlation(k, v, context=ctx) + ctx = baggage.set_baggage(k, v, context=ctx) output = {} self.propagator.inject(dict.__setitem__, output, context=ctx) - return output.get("otcorrelationcontext") + return output.get("otcorrelations") def test_no_context_header(self): - correlations = correlationcontext.get_correlations( + baggage_entries = baggage.get_all( self.propagator.extract(get_as_list, {}) ) - self.assertEqual(correlations, {}) + self.assertEqual(baggage_entries, {}) def test_empty_context_header(self): header = "" @@ -94,7 +90,7 @@ def test_invalid_header(self): self.assertEqual(self._extract(header), expected) def test_header_too_long(self): - long_value = "s" * (CorrelationContextPropagator.MAX_HEADER_LENGTH + 1) + long_value = "s" * (BaggagePropagator.MAX_HEADER_LENGTH + 1) header = "key1={}".format(long_value) expected = {} self.assertEqual(self._extract(header), expected) @@ -103,20 +99,20 @@ def test_header_contains_too_many_entries(self): header = ",".join( [ "key{}=val".format(k) - for k in range(CorrelationContextPropagator.MAX_PAIRS + 1) + for k in range(BaggagePropagator.MAX_PAIRS + 1) ] ) self.assertEqual( - len(self._extract(header)), CorrelationContextPropagator.MAX_PAIRS + len(self._extract(header)), BaggagePropagator.MAX_PAIRS ) def test_header_contains_pair_too_long(self): - long_value = "s" * (CorrelationContextPropagator.MAX_PAIR_LENGTH + 1) + long_value = "s" * (BaggagePropagator.MAX_PAIR_LENGTH + 1) header = "key1=value1,key2={},key3=value3".format(long_value) expected = {"key1": "value1", "key3": "value3"} self.assertEqual(self._extract(header), expected) - def test_inject_no_correlations(self): + def test_inject_no_baggage_entries(self): values = {} output = self._inject(values) self.assertEqual(None, output) diff --git a/opentelemetry-api/tests/correlationcontext/test_correlation_context.py b/opentelemetry-api/tests/correlationcontext/test_correlation_context.py deleted file mode 100644 index aaa5d9fa925..00000000000 --- a/opentelemetry-api/tests/correlationcontext/test_correlation_context.py +++ /dev/null @@ -1,71 +0,0 @@ -# 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. - -import unittest - -from opentelemetry import context -from opentelemetry import correlationcontext as cctx - - -class TestCorrelationContextManager(unittest.TestCase): - def test_set_correlation(self): - self.assertEqual({}, cctx.get_correlations()) - - ctx = cctx.set_correlation("test", "value") - self.assertEqual(cctx.get_correlation("test", context=ctx), "value") - - ctx = cctx.set_correlation("test", "value2", context=ctx) - self.assertEqual(cctx.get_correlation("test", context=ctx), "value2") - - def test_correlations_current_context(self): - token = context.attach(cctx.set_correlation("test", "value")) - self.assertEqual(cctx.get_correlation("test"), "value") - context.detach(token) - self.assertEqual(cctx.get_correlation("test"), None) - - def test_set_multiple_correlations(self): - ctx = cctx.set_correlation("test", "value") - ctx = cctx.set_correlation("test2", "value2", context=ctx) - self.assertEqual(cctx.get_correlation("test", context=ctx), "value") - self.assertEqual(cctx.get_correlation("test2", context=ctx), "value2") - self.assertEqual( - cctx.get_correlations(context=ctx), - {"test": "value", "test2": "value2"}, - ) - - def test_modifying_correlations(self): - ctx = cctx.set_correlation("test", "value") - self.assertEqual(cctx.get_correlation("test", context=ctx), "value") - correlations = cctx.get_correlations(context=ctx) - with self.assertRaises(TypeError): - correlations["test"] = "mess-this-up" - self.assertEqual(cctx.get_correlation("test", context=ctx), "value") - - def test_remove_correlations(self): - self.assertEqual({}, cctx.get_correlations()) - - ctx = cctx.set_correlation("test", "value") - ctx = cctx.set_correlation("test2", "value2", context=ctx) - ctx = cctx.remove_correlation("test", context=ctx) - self.assertEqual(cctx.get_correlation("test", context=ctx), None) - self.assertEqual(cctx.get_correlation("test2", context=ctx), "value2") - - def test_clear_correlations(self): - self.assertEqual({}, cctx.get_correlations()) - - ctx = cctx.set_correlation("test", "value") - self.assertEqual(cctx.get_correlation("test", context=ctx), "value") - - ctx = cctx.clear_correlations(context=ctx) - self.assertEqual(cctx.get_correlations(context=ctx), {}) diff --git a/opentelemetry-api/tests/propagators/test_global_httptextformat.py b/opentelemetry-api/tests/propagators/test_global_httptextformat.py index a7e94302233..a1c58a4c3ad 100644 --- a/opentelemetry-api/tests/propagators/test_global_httptextformat.py +++ b/opentelemetry-api/tests/propagators/test_global_httptextformat.py @@ -15,7 +15,7 @@ import typing import unittest -from opentelemetry import correlationcontext, trace +from opentelemetry import baggage, trace from opentelemetry.propagators import extract, inject from opentelemetry.trace import get_current_span, set_span_in_context @@ -41,28 +41,28 @@ def test_propagation(self): ) tracestate_value = "foo=1,bar=2,baz=3" headers = { - "otcorrelationcontext": ["key1=val1,key2=val2"], + "otcorrelations": ["key1=val1,key2=val2"], "traceparent": [traceparent_value], "tracestate": [tracestate_value], } ctx = extract(get_as_list, headers) - correlations = correlationcontext.get_correlations(context=ctx) + baggage_entries = baggage.get_all(context=ctx) expected = {"key1": "val1", "key2": "val2"} - self.assertEqual(correlations, expected) + self.assertEqual(baggage_entries, expected) span_context = get_current_span(context=ctx).get_context() self.assertEqual(span_context.trace_id, self.TRACE_ID) self.assertEqual(span_context.span_id, self.SPAN_ID) span = trace.DefaultSpan(span_context) - ctx = correlationcontext.set_correlation("key3", "val3") - ctx = correlationcontext.set_correlation("key4", "val4", context=ctx) + ctx = baggage.set_baggage("key3", "val3") + ctx = baggage.set_baggage("key4", "val4", context=ctx) ctx = set_span_in_context(span, context=ctx) output = {} inject(dict.__setitem__, output, context=ctx) self.assertEqual(traceparent_value, output["traceparent"]) - self.assertIn("key3=val3", output["otcorrelationcontext"]) - self.assertIn("key4=val4", output["otcorrelationcontext"]) + self.assertIn("key3=val3", output["otcorrelations"]) + self.assertIn("key4=val4", output["otcorrelations"]) self.assertIn("foo=1", output["tracestate"]) self.assertIn("bar=2", output["tracestate"]) self.assertIn("baz=3", output["tracestate"]) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py index 2af8a551ee1..f3d31195f62 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py @@ -132,7 +132,7 @@ class Metric(metrics_api.Metric): This is the class that is used to represent a metric that is to be synchronously recorded and tracked. Synchronous instruments are called inside a request, meaning they have an associated distributed context - (i.e. Span context, correlation context). Multiple metric events may occur + (i.e. Span context, baggage). Multiple metric events may occur for a synchronous instrument within a give collection interval. Each metric has a set of bound metrics that are created from the metric.