LiteBus
CatalogTransport

Transport Tracing

  • ID: transport.tracing
  • Name: Transport tracing
  • Maturity: GA
  • Summary: Records broker send and message processing activities through one transport activity source.

Behavior

Concrete broker publishers start one producer activity around the SDK send call. TransportConsumerHandlerInvoker starts one consumer activity around the application delivery handler. Durable inbox and outbox dispatchers do not add another transport activity, so one broker operation produces one transport span.

Span names follow the OpenTelemetry messaging form {operation} {destination}. Sending to orders records send orders; processing from orders records process orders. If no destination is available, the name is send or process.

Public Surface

APIRole
TransportTracing.ActivitySourceShared ActivitySource instance
TransportTracing.StartPublishActivity(TransportActivityMetadata)Starts a producer activity
TransportTracing.StartConsumeActivity(TransportMessage)Starts a consumer activity
TransportTracing.RecordException(Activity, Exception)Records error.type and error status
TransportActivityMetadataBroker-neutral send activity input
TransportMessagingSystemsWell-known messaging system values used by built-in adapters
LiteBusTransportTelemetry.ActivitySourceNameSource name LiteBus.Transport
LiteBusTransportTelemetry.PublishOperationNameSend operation name
LiteBusTransportTelemetry.ConsumeOperationNameProcess operation name

Messaging System Values

Adaptermessaging.system
RabbitMQ-compatible AMQPrabbitmq
Amazon SQSaws_sqs
Azure Service Busservicebus
Apache Kafkakafka
LiteBus in-memory transportlitebus_in_memory
Custom transport without an identifierlitebus

Custom consumer adapters should set TransportMessage.MessagingSystem to the OpenTelemetry value for the broker. The fallback value identifies LiteBus instrumentation but cannot distinguish the underlying system.

Activity Attributes

Every send and process activity records these required attributes:

AttributeValue
messaging.systemAdapter messaging system
messaging.operation.namesend or process
messaging.operation.typesend or process

Optional message metadata uses these attributes:

AttributeSource
messaging.destination.nameDestination
messaging.message.idMessage identifier
messaging.message.conversation_idCorrelation identifier
litebus.transport.routeBroker-neutral route
litebus.transport.redeliveredtrue after a prior delivery attempt
messaging.kafka.message.keyRoute on Kafka only
messaging.rabbitmq.destination.routing_keyRoute on RabbitMQ-compatible AMQP only

messaging.kafka.message.key is never emitted for AMQP, SQS, Azure Service Bus, or the in-memory transport.

Parenting and Stored Trace Context

Send activities retain Activity.Current as their parent. Process activities read TransportHeaders.TraceContext when it contains either a W3C traceparent string or JSON with traceparent and optional tracestate properties.

When no ambient activity exists, a valid stored W3C context becomes the process parent. When an ambient activity exists, it remains the parent and the stored remote context is added as an activity link. Invalid or malformed trace context is ignored.

LiteBus copies the durable trace context header supplied by the message envelope. Broker-native trace header injection is outside this capability.

Error Recording

Publisher failures and consumer handler failures set ActivityStatusCode.Error and record the canonical exception type in error.type. LiteBus does not copy exception messages into transport span attributes or status descriptions. Circuit breaker transitions can add these activity events while a transport activity is current:

  • litebus.transport.circuit_breaker.failure_recorded
  • litebus.transport.circuit_breaker.opened

Registration

Register the source on the tracer provider:

using LiteBus.Transport.Extensions.OpenTelemetry;

services.AddOpenTelemetry()
    .WithTracing(tracing => tracing.AddLiteBusTransportInstrumentation());

The extension subscribes LiteBusTransportTelemetry.ActivitySourceName. Exporters and sampling remain host configuration.

Tests

TransportTracingTests covers:

  • Kafka producer and RabbitMQ consumer attributes.
  • Omission of blank optional attributes.
  • Ambient send parenting.
  • Serialized W3C remote parent continuation.
  • Error status and error.type recording.

LiteBusTransportOpenTelemetryIntegrationTests verifies activity source and meter provider registration.

On this page