OpenTracingManager — The trace manager

class cdumay_opentracing.OpenTracingManager

This class manages the opentracing context.

  • It allows to recover using the opentracing library the initialized tracer.
  • It manage spans stack
classmethod register(clazz, driver)

Register a driver for the given class

Parameters:
classmethod get_driver(obj)

Find registered driver for the given object

Parameters:obj (Any) – object to manipulate
Returns:registered driver for this class
Return type:cdumay_opentracing.OpenTracingDriver
classmethod tags(obj)

Extract tags from carrier object using a registered driver.

Parameters:obj (Any) – object to manipulate
Returns:Tags to add on span
Return type:dict
classmethod get_current_span()

Get the current span

Returns:The current span
Return type:opentracing.span.Span or None
classmethod create_span(obj, name, tags)

Create a new span

Parameters:
  • obj (Any) – Any object
  • name (str) – Span name
  • tags (dict) – Additional tags
Returns:

Span

Return type:

opentracing.span.Span

classmethod finish_span(span)

Terminate the given span

Parameters:span (opentracing.span.Span) – Span to finish
classmethod log_kv(span, obj, event, **kwargs)

Adds a log record to the Span.

Parameters:
  • span (opentracing.span.Span) – the Span instance to use.
  • obj (Any) – the carrier object.
  • event (str) – Span event name.
  • kwargs (dict) – A dict of string keys and values of any type to log
Returns:

Returns the Span itself, for call chaining.

Return type:

opentracing.span.Span