Class TracingBehavior<TMessage, TResponse>
Pipeline behavior that creates an OpenTelemetry Activity for each command/query. Tags the activity with Result status and error details on failure.
public sealed class TracingBehavior<TMessage, TResponse> : IPipelineBehavior<TMessage, TResponse> where TMessage : IMessage where TResponse : IResult
Type Parameters
TMessageThe message type.
TResponseThe response type, constrained to IResult.
- Inheritance
-
TracingBehavior<TMessage, TResponse>
- Implements
-
IPipelineBehavior<TMessage, TResponse>
- Inherited Members
- Extension Methods
Constructors
TracingBehavior(TrellisMediatorTelemetryOptions?)
Initializes a new instance of the TracingBehavior<TMessage, TResponse> class.
public TracingBehavior(TrellisMediatorTelemetryOptions? options = null)
Parameters
optionsTrellisMediatorTelemetryOptionsTelemetry redaction options resolved from DI. When
null(i.e. not registered) the safe-by-default options are used and Detail is redacted from the activity status description.
Fields
ActivitySourceName
The name used for the Trellis.Mediator.TracingBehavior<TMessage, TResponse>.ActivitySource that traces mediator pipeline operations.
public const string ActivitySourceName = "Trellis.Mediator"
Field Value
Methods
Handle(TMessage, MessageHandlerDelegate<TMessage, TResponse>, CancellationToken)
public ValueTask<TResponse> Handle(TMessage message, MessageHandlerDelegate<TMessage, TResponse> next, CancellationToken cancellationToken)
Parameters
messageTMessagenextMessageHandlerDelegate<TMessage, TResponse>cancellationTokenCancellationToken
Returns
- ValueTask<TResponse>