Class TransportMeter
Provides OpenTelemetry-compatible metrics for transport adapter operations using System.Diagnostics.Metrics.
public static class TransportMeter
- Inheritance
-
TransportMeter
- Inherited Members
Remarks
This follows .NET best practices by using built-in APIs that OpenTelemetry can collect from, without requiring a direct dependency on OpenTelemetry.
Metric names follow the OpenTelemetry semantic conventions with the dispatch.transport prefix:
dispatch.transport.messages_sent_total- Counter of messages sentdispatch.transport.messages_received_total- Counter of messages receiveddispatch.transport.errors_total- Counter of transport errorsdispatch.transport.send.duration- Histogram of send operation durationsdispatch.transport.receive.duration- Histogram of receive operation durationsdispatch.transport.connection_status- Gauge of connection status (0=disconnected, 1=connected)
Fields
MeterName
The meter name for transport metrics.
public const string MeterName = "Excalibur.Dispatch.Transport"
Field Value
MeterVersion
The meter version.
public const string MeterVersion = "1.0.0"
Field Value
Methods
RecordError(string, string, string)
Records a transport error.
public static void RecordError(string transportName, string transportType, string errorType)
Parameters
transportNamestringThe name of the transport.
transportTypestringThe type of transport.
errorTypestringThe type of error (e.g., "timeout", "connection_failed", "serialization_error").
RecordMessageReceived(string, string, string?)
Records that a message was received through a transport.
public static void RecordMessageReceived(string transportName, string transportType, string? messageType = null)
Parameters
transportNamestringThe name of the transport.
transportTypestringThe type of transport.
messageTypestringOptional message type.
RecordMessageSent(string, string, string?)
Records that a message was sent through a transport.
public static void RecordMessageSent(string transportName, string transportType, string? messageType = null)
Parameters
transportNamestringThe name of the transport.
transportTypestringThe type of transport.
messageTypestringOptional message type.
RecordReceiveDuration(string, string, double)
Records the duration of a receive operation.
public static void RecordReceiveDuration(string transportName, string transportType, double durationMs)
Parameters
transportNamestringThe name of the transport.
transportTypestringThe type of transport.
durationMsdoubleDuration in milliseconds.
RecordSendDuration(string, string, double)
Records the duration of a send operation.
public static void RecordSendDuration(string transportName, string transportType, double durationMs)
Parameters
transportNamestringThe name of the transport.
transportTypestringThe type of transport.
durationMsdoubleDuration in milliseconds.
RecordTransportStarted(string, string)
Records that a transport was started.
public static void RecordTransportStarted(string transportName, string transportType)
Parameters
RecordTransportStopped(string, string)
Records that a transport was stopped.
public static void RecordTransportStopped(string transportName, string transportType)
Parameters
RemoveTransport(string)
Removes a transport from metric tracking.
public static void RemoveTransport(string transportName)
Parameters
transportNamestringThe name of the transport to remove.
UpdateTransportState(string, string, bool, long)
Updates the current state metrics for a transport.
public static void UpdateTransportState(string transportName, string transportType, bool isConnected, long pendingMessages = 0)