Table of Contents

Class TracingBehavior<TMessage, TResponse>

Namespace
Trellis.Mediator
Assembly
Trellis.Mediator.dll

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

TMessage

The message type.

TResponse

The 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

options TrellisMediatorTelemetryOptions

Telemetry 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

string

Methods

Handle(TMessage, MessageHandlerDelegate<TMessage, TResponse>, CancellationToken)

public ValueTask<TResponse> Handle(TMessage message, MessageHandlerDelegate<TMessage, TResponse> next, CancellationToken cancellationToken)

Parameters

message TMessage
next MessageHandlerDelegate<TMessage, TResponse>
cancellationToken CancellationToken

Returns

ValueTask<TResponse>