python opentracing with jaeger extract span not logging in UI using microservices

Viewed 612

I have a problem using the jaeger open tracing project within our microservice system. The config I use is as below.

        config = Config(
            config={
                'sampler': {
                    'type': 'const',
                    'param': 1,
                },
                'local_agent': {
                    'reporting_host': '127.0.0.1',
                },
                'logging': True,
            },
            service_name='DB - API',
            validate=True,
        )

        tracer = config.initialize_tracer()
        active_span_source = FixedActiveSpanSource()
        tracer_interceptor = open_tracing_client_interceptor(
            tracer,
            log_payloads=True,
            active_span_source=active_span_source)

The origin of the trace is the same as this.

            with t.tracer.start_span('Request Post') as span:
                print(
                    f"Created span: trace_id:{span.trace_id:x}, span_id:{span.span_id:x}, parent_id:{span.parent_id}, flags:{span.flags:x}")
                span.log_kv({'event': 'Request Posted', 'life': 42})
                with t.tracer.start_span('GraphQl', child_of=span) as span2:
                    span2.log_kv({'event': 'Graphql Executed', 'life': 42})
                    carrier = {}
                    t.tracer.inject(span, Format.HTTP_HEADERS, carrier)
                    print(carrier)

This works fine and is logged within the UI and with printed results below.

Created span: trace_id:2b55203a8773aa14, span_id:77cceca94f4cfe74, parent_id:None, flags:1
{'uber-trace-id': '2b55203a8773aa14:77cceca94f4cfe74:0:1'}

But then when I extract {'uber-trace-id': '2b55203a8773aa14:77cceca94f4cfe74:0:1'} within another service it says a new span has been created as expected, but nothing is logged within the UI.

    carrier = {'uber-trace-id': '2b55203a8773aa14:77cceca94f4cfe74:0:1'}

    parentspan = t.tracer.extract(Format.HTTP_HEADERS, carrier)
    print(t.tracer.sampler)
    with t.tracer.start_span('TEST', child_of=parentspan) as span3:
        print(
            f"Created span: trace_id:{span3.trace_id:x}, span_id:{span3.span_id:x}, parent_id:{span3.parent_id:x}, flags:{span3.flags:x}")
        span3.log_kv({'event': 'test', 'life': 42})
        time.sleep(1)
        span3.log_kv({'event': 'test34', 'life': 43})
        time.sleep(30)

Print result:

Created span: trace_id:2b55203a8773aa14, span_id:af7fef928ff1cd13, parent_id:77cceca94f4cfe74, flags:1

With both Format.HTTP_HEADERS and Format.TEXT_MAP it is the same result. Does anyone know why nothing is logged in the UI and how to fix this?

Thanks in advance.

0 Answers
Related