Before you can view the trace data of your application in the Tracing Analysis console, you must use a client to report the trace data to Tracing Analysis. This topic shows you how to use Jaeger to report Python application data.
Prerequisites
- Log on to Tracing Analysis console, in the Region-specific Information area, turn on View Token.
- In the Client area, click the desired tracing client.
- In the Related Information column in the table below, click the copy icon at the end of Endpoint information.
Background information
The workflow of reporting data directly without Agent is as shown in the following figure.
The workflow of reporting data through Agent is as shown in the following figure.
Procedure
Use of Jaeger
-
Create a Tracer object
from jaeger_client import Config def init_jaeger_tracer(service_name='your-app-name'): config = Config(config={}, service_name=service_name) return config.initialize_tracer()
-
Create and finish a span
// Start a span that does not have a parent span. tracer.start_span('TestSpan') // Start a span that has a parent span. tracer.start_span('ChildSpan', child_of=span) // Finish the span. span.finish()
-
Pass a SpanContext
// Serialization: Inject a SpanContext and pass it to the next span. tracer.inject( span_context=span.context, format=Format.TEXT_MAP, carrier=carrier ) // Deserialization: Extract a SpanContext that is passed. span_ctx = tracer.extract(format=Format.TEXT_MAP, carrier={})