Skip to content

mediator: built-in middlewares (TracingMiddleware, LoggingMiddleware, TimeoutMiddleware) #7

@pierrick-fonquerne

Description

@pierrick-fonquerne

Ship three production-ready middlewares so users get observability out of the box without writing boilerplate.

Scope

  • TracingMiddleware: opens an OpenTelemetry span per dispatch keyed on command type, MessageId and CorrelationId.
  • LoggingMiddleware: emits a tracing::info! event before and after each dispatch with elapsed time.
  • TimeoutMiddleware: cancels the dispatch after a configurable Duration, returns HexeractError::Timeout.

Acceptance criteria

  • TracingMiddleware records message_id and correlation_id as span attributes.
  • LoggingMiddleware output includes the command type name and elapsed milliseconds.
  • TimeoutMiddleware returns HexeractError::Timeout when the handler exceeds the deadline.
  • All three middlewares implement Clone and are usable without Arc wrapping.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:featureNew capabilityphase:observabilityTracing, logging, metrics and built-in middlewares

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions