nsb-diagnostics-poc

November 21, 2022 ยท View on GitHub

This code example shows integration with OpenTelemetry and W3C trace context

It requires RabbitMQ and Zipkin (just use Docker for both) to run.

Values based on https://github.com/open-telemetry/opentelemetry-specification/pull/418

Messaging attributes

Attribute nameNotes and examplesRequired?NServiceBus Value
messaging.systemA string identifying the messaging system vendor such as kafka, rabbitmq or activemq.YesReadOnlySettings.Get().GetType().Name.Replace("Transport", null).ToLowerInvariant()
messaging.destinationThe message destination name, e.g. MyQueue or MyTopic. This might be equal to the span name but is required nevertheless.YesReadOnlySettings.LogicalAddress().ToString()
messaging.destination_kindThe kind of message destination: Either queue or topic.Yes, if either of them applies.Translated from the MessageIntentEnum in the message and OutboundRoutingType
messaging.temp_destinationA boolean that is true if the message destination is temporary.If temporary (assumed to be false if missing).
messaging.protocolThe name of the transport protocol such as AMQP or MQTT.No
messaging.protocol_versionThe version of the transport protocol such as 0.9.1.No
messaging.urlConnection string such as tibjmsnaming://localhost:7222 or https://queue.amazonaws.com/80398EXAMPLE/MyQueue.No
messaging.message_idA value used by the messaging system as an identifier for the message, represented as a string.NoMessage.MessageId
messaging.conversation_idA value identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID".No"NServiceBus.ConversationId" header

avg(rate(messaging_client_server_duration_ms_count[5m]))

Prometheus

To integrate with Prometheus, in the root run a Prometheus instance with Docker:

docker run `
    -p 9090:9090 `
    -v ${PWD}/prometheus.yml:/etc/prometheus/prometheus.yml `
    prom/prometheus