from jaeger_client import Config
import time
from os import getenv
JAEGER_HOST = getenv('JAEGER_HOST', 'localhost')
SERVICE_NAME = getenv('JAEGER_HOST', 'my_service_test')
def build_your_span(tracer):
with tracer.start_span('yourTestSpan') as span:
span.log_kv({'event': 'test your message', 'life': 42})
span.set_tag("span.kind", "server")
return span
def build_your_tracer():
my_config = Config(
config={
'sampler': {
'type': 'const',
'param': 1,
},
'local_agent': {
'reporting_host': JAEGER_HOST,
'reporting_port': 6831,
},
'logging': True,
},
service_name=SERVICE_NAME,
validate=True
)
tracer = my_config.initialize_tracer()
return tracer
if __name__ == "__main__":
tracer = build_your_tracer()
span = build_your_span(tracer)
time.sleep(2)
tracer.close()
Was this page helpful?