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

Move instrumentation opentracing shim #109

Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ packages=find_namespace:
install_requires =
Deprecated >= 1.2.6
opentracing ~= 2.0
opentelemetry-api == 0.15.dev0
opentelemetry-api == 0.15b0

[options.extras_require]
test =
opentelemetry-test == 0.15.dev0
opentelemetry-test == 0.15b0
opentracing ~= 2.2.0

[options.packages.find]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
get_current_span,
set_span_in_context,
)
from opentelemetry.trace.propagation.textmap import DictGetter
from opentelemetry.util.types import Attributes

ValueT = TypeVar("ValueT", int, float, bool, str)
Expand Down Expand Up @@ -527,6 +528,7 @@ def __init__(self, tracer: OtelTracer):
Format.TEXT_MAP,
Format.HTTP_HEADERS,
)
self._carrier_getter = DictGetter()

def unwrap(self):
"""Returns the :class:`opentelemetry.trace.Tracer` object that is
Expand Down Expand Up @@ -710,12 +712,8 @@ def extract(self, format: object, carrier: object):
if format not in self._supported_formats:
raise UnsupportedFormatException

def get_as_list(dict_object, key):
value = dict_object.get(key)
return [value] if value is not None else []

propagator = propagators.get_global_textmap()
ctx = propagator.extract(get_as_list, carrier)
ctx = propagator.extract(self._carrier_getter, carrier)
span = get_current_span(ctx)
if span is not None:
otel_context = span.get_span_context()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.15.dev0"
__version__ = "0.15b0"