Repository: open-telemetry/opentelemetry-python

Issue:
Jaeger propagator must be distributed as a separate package
As per spec, the propagators must be distributed as separate packages:

> The official list of propagators that MUST be maintained by the OpenTelemetry organization and MUST be distributed as OpenTelemetry extension packages

https://github.com/open-telemetry/opentelemetry-specification/blob/2ebefc181a99dc79bbb4b1d3e85e20b240a5f26f/specification/context/api-propagators.md#propagators-distribution


Discussion:

Resolving patch:
diff --git a/propagator/opentelemetry-propagator-jaeger/setup.py b/propagator/opentelemetry-propagator-jaeger/setup.py
new file mode 100644
--- /dev/null
+++ b/propagator/opentelemetry-propagator-jaeger/setup.py
@@ -0,0 +1,26 @@
+# 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 os
+
+import setuptools
+
+BASE_DIR = os.path.dirname(__file__)
+VERSION_FILENAME = os.path.join(
+    BASE_DIR, "src", "opentelemetry", "propagators", "jaeger", "version.py"
+)
+PACKAGE_INFO = {}
+with open(VERSION_FILENAME) as f:
+    exec(f.read(), PACKAGE_INFO)
+
+setuptools.setup(version=PACKAGE_INFO["__version__"])
diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/propagation/jaeger_propagator.py b/propagator/opentelemetry-propagator-jaeger/src/opentelemetry/propagators/jaeger/__init__.py
similarity index 93%
rename from opentelemetry-sdk/src/opentelemetry/sdk/trace/propagation/jaeger_propagator.py
rename to propagator/opentelemetry-propagator-jaeger/src/opentelemetry/propagators/jaeger/__init__.py
--- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/propagation/jaeger_propagator.py
+++ b/propagator/opentelemetry-propagator-jaeger/src/opentelemetry/propagators/jaeger/__init__.py
@@ -18,7 +18,6 @@
 import opentelemetry.trace as trace
 from opentelemetry import baggage
 from opentelemetry.context import Context, get_current
-from opentelemetry.sdk.trace.propagation import extract_first_element
 from opentelemetry.trace.propagation.textmap import (
     Getter,
     Setter,
@@ -46,7 +45,7 @@ def extract(
 
         if context is None:
             context = get_current()
-        fields = extract_first_element(
+        fields = _extract_first_element(
             getter.get(carrier, self.TRACE_ID_KEY)
         ).split(":")
 
@@ -122,7 +121,7 @@ def _extract_baggage(self, getter, carrier, context):
             if key.startswith(self.BAGGAGE_PREFIX)
         ]
         for key in baggage_keys:
-            value = extract_first_element(getter.get(carrier, key))
+            value = _extract_first_element(getter.get(carrier, key))
             context = baggage.set_baggage(
                 key.replace(self.BAGGAGE_PREFIX, ""),
                 urllib.parse.unquote(value).strip(),
@@ -135,3 +134,11 @@ def _format_uber_trace_id(trace_id, span_id, parent_span_id, flags):
     return "{:032x}:{:016x}:{:016x}:{:02x}".format(
         trace_id, span_id, parent_span_id, flags
     )
+
+
+def _extract_first_element(
+    items: typing.Iterable[TextMapPropagatorT],
+) -> typing.Optional[TextMapPropagatorT]:
+    if items is None:
+        return None
+    return next(iter(items), None)
diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/propagation/__init__.py b/propagator/opentelemetry-propagator-jaeger/src/opentelemetry/propagators/jaeger/version.py
similarity index 67%
rename from opentelemetry-sdk/src/opentelemetry/sdk/trace/propagation/__init__.py
rename to propagator/opentelemetry-propagator-jaeger/src/opentelemetry/propagators/jaeger/version.py
--- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/propagation/__init__.py
+++ b/propagator/opentelemetry-propagator-jaeger/src/opentelemetry/propagators/jaeger/version.py
@@ -12,15 +12,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
-import typing
-
-from opentelemetry.trace.propagation.textmap import TextMapPropagatorT
-
-
-def extract_first_element(
-    items: typing.Iterable[TextMapPropagatorT],
-) -> typing.Optional[TextMapPropagatorT]:
-    if items is None:
-        return None
-    return next(iter(items), None)
+__version__ = "0.17.dev0"


Test patch:
diff --git a/propagator/opentelemetry-propagator-jaeger/tests/__init__.py b/propagator/opentelemetry-propagator-jaeger/tests/__init__.py
new file mode 100644
--- /dev/null
+++ b/propagator/opentelemetry-propagator-jaeger/tests/__init__.py
@@ -0,0 +1,13 @@
+# 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.
diff --git a/opentelemetry-sdk/tests/trace/propagation/test_jaeger_propagator.py b/propagator/opentelemetry-propagator-jaeger/tests/test_jaeger_propagator.py
similarity index 98%
rename from opentelemetry-sdk/tests/trace/propagation/test_jaeger_propagator.py
rename to propagator/opentelemetry-propagator-jaeger/tests/test_jaeger_propagator.py
--- a/opentelemetry-sdk/tests/trace/propagation/test_jaeger_propagator.py
+++ b/propagator/opentelemetry-propagator-jaeger/tests/test_jaeger_propagator.py
@@ -17,9 +17,11 @@
 
 import opentelemetry.sdk.trace as trace
 import opentelemetry.sdk.trace.ids_generator as ids_generator
-import opentelemetry.sdk.trace.propagation.jaeger_propagator as jaeger
 import opentelemetry.trace as trace_api
 from opentelemetry import baggage
+from opentelemetry.propagators import (  # pylint: disable=no-name-in-module
+    jaeger,
+)
 from opentelemetry.trace.propagation.textmap import DictGetter
 
 FORMAT = jaeger.JaegerPropagator()