Skip to content

Instantly share code, notes, and snippets.

@juanpabloaj juanpabloaj/
Created Feb 21, 2018

What would you like to do?
# -*- coding: utf-8 -*-
import logging
import time
from jaeger_client import Config
from opentracing.propagation import Format
if __name__ == "__main__":
log_level = logging.DEBUG
logging.getLogger('').handlers = []
logging.basicConfig(format='%(asctime)s %(message)s', level=log_level)
config = Config(
config={ # usually read from some yaml config
'sampler': {
'type': 'const',
'param': 1,
'logging': True,
# this call also sets opentracing.tracer
tracer = config.initialize_tracer()
with tracer.start_span('TestSpan') as span:
span.log_event('test message', payload={'life': 42})
headers = {}
tracer.inject(span, Format.HTTP_HEADERS, headers)
with tracer.start_span('ChildSpan', child_of=span) as child_span:
span.log_event('down below')
headers = {}
tracer.inject(child_span, Format.HTTP_HEADERS, headers)
with tracer.start_span('ChildSpan', child_of=child_span) as last_child:
span.log_event('down below')
headers = {}
tracer.inject(last_child, Format.HTTP_HEADERS, headers)
time.sleep(2) # yield to IOLoop to flush the spans -
tracer.close() # flush any buffered spans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.