The tracing support is added using OpenTelemetry-cpp.
There are two types of spans:
Library generated spans:
Send span ("amqp-message-send”) gets created just before sending a message and ends when that message gets settled.
Receive span ("amqp-message-received") gets created just before receiving a message and ends as soon as the message is received.
Application generated spans:
Users can also create their own spans and those spans will get linked with the library generated spans.
opentelemetry::exporter::jaeger::JaegerExporterOptions opts; std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> exporter = std::unique_ptr<opentelemetry::sdk::trace::SpanExporter>( new opentelemetry::exporter::jaeger::JaegerExporter(opts));
Above is an example of initializing a jaeger exporter. Apart from jaeger exporter, there are many other exporters supported by OpenTelelemetry.
auto processor = std::unique_ptr<opentelemetry::sdk::trace::SpanProcessor>( new opentelemetry::sdk::trace::SimpleSpanProcessor(std::move(exporter))); auto provider = opentelemetry::nostd::shared_ptr<opentelemetry::trace::TracerProvider>( new opentelemetry::sdk::trace::TracerProvider(std::move(processor)); opentelemetry::trace::Provider::SetTracerProvider(provider);
proton::initOpenTelemetryTracer();
This will generates the library spans ("amqp-message-send" and "amqp-message-received").
In addition, users can create their own spans in the application. The tracing_client and tracing_server examples demonstrates how to do that with jaeger exporter.
A working example of distributed tracing using broker, tracing_server and tracing_client examples.
docker run -d –name jaeger \ -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \ -p 5775:5775/udp \ -p 6831:6831/udp \ -p 6832:6832/udp \ -p 5778:5778 \ -p 16686:16686 \ -p 14268:14268 \ -p 14250:14250 \ -p 9411:9411 \ jaegertracing/all-in-one:1.25
Note: Thrift is jaeger exporter dependency.
WORKDIR cpp/examples
./broker
./tracing_server
./tracing_client
Browse to http://localhost:16686/. This should open up a console for the Jaeger tracing system.
Select the Service dropdown at the top of the Search options (if not already selected). Hit Find Traces.