Sourced.Middleware.Telemetry (sourced v0.2.0)

Copy Markdown View Source

Wraps the pipeline in a :telemetry.span/3, one span per operation.

Emits :start, :stop, and :exception events under:

  • [:sourced, :event_store, :append, _]
  • [:sourced, :event_store, :query, _]
  • [:sourced, :event_store, :subscribe, _]
  • [:sourced, :event_store, :notify, _]

Start metadata carries %{store: adapter_module} plus the operation's inputs — events for appends and notifications, opts for queries and subscribes. Stop metadata adds :outcome, the operation's result ({:ok, ...} or {:error, reason}).

A :notify span covers delivering one batch of live events to one subscriber, and is emitted from the adapter's process rather than a caller's.

This middleware normally sits near the top of the stack so its span covers the work of the middleware below it — a domain middleware placed inside it means the :outcome carries decoded events. See Sourced.EventStore.