Skip to content

Instantly share code, notes, and snippets.

@wkiser
Created January 2, 2018 22:57
Show Gist options
  • Save wkiser/415ffdce73c99a45cc6b66ae8db0b013 to your computer and use it in GitHub Desktop.
Save wkiser/415ffdce73c99a45cc6b66ae8db0b013 to your computer and use it in GitHub Desktop.
import opentracing
import logging
import time
from jaeger_client import Config
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,
},
service_name='your/app/name',
)
# 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})
with tracer.start_span('ChildSpan', child_of=span) as child_span:
span.log_event('down below')
time.sleep(
2) # yield to IOLoop to flush the spans - https://github.com/jaegertracing/jaeger-client-python/issues/50
tracer.close() # flush any buffered spans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment