Skip to content

Tracing

Daniel Blankensteiner edited this page Apr 22, 2024 · 4 revisions

Tracing

DotPulsar support tracing from version 2.0.0 following the guidelines from the OpenTelemetry project.

Enabling tracing

All that's needed for tracing to work is to add the 'DotPulsar' source to OpenTelemetry's TracerProviderBuilder.

.ConfigureServices(services =>
{
    services.AddOpenTelemetryTracing(builder =>
	{
	    builder.AddSource("DotPulsar");
	});
})

For more in-depth information about OpenTelemetry for .NET you can read the getting started section and browse the git repository.

Sending a message

If the 'DotPulsar' source is active a producer trace will be created when sending messages with the producer. The conversation id can optionally be set via the 'SetConversationId' extension method for MessageMetadata. If the conversation id is set, it will be added to the trace.

Processing a message

If the 'DotPulsar' source is active a consumer trace will be created when processing messages with the 'Process' extension method for IConsumer<TMessage>. If the conversion id was added to the message's metadata, it will automatically be added to the trace.

Linking the 'Send trace' and 'Process trace'

DotPulsar can be configured to link the trace created when processing the message to the trace created when the message was sent.

Attaching trace info to the message

To add trace information to the message's metadata when sending just set 'AttachTraceInfoToMessages' on the ProducerBuilder to true.

Linking while processing

To link the process trace to the send trace use the 'Process' extension method for IConsumer and set 'LinkTraces' on the ProcessingOptions to true.