PouryaKit
ReferencePackages

PouryaKit.Observability

An activity and a duration metric for every command and query.

An activity and a duration metric for every command and query. Each Operation the dispatcher runs is one activity and one measurement, tagged with its type, its Actor kind and its outcome, and with its Module in a Host of Modules, and the Outbox carries the trace into each delivery, in one Host or across RabbitMQ. It emits through System.Diagnostics only: exporting is the Host's job.

Install

dotnet add package PouryaKit.Observability --prerelease

When to use it

  • You observe the Host's Operations as activities and duration metrics.
  • You choose what the Host's exporter listens to.
  • You follow one trace from an Operation through the Outbox into its deliveries.
  • You assert telemetry in a test with listeners.

It wraps the dispatcher of PouryaKit.Cqrs. The Host recipes hold the standard OpenTelemetry setup that exports it.

Quick start

Register it in the Host, after the Modules:

builder.AddPouryaKitModules(modules => modules.Add<InventoryModule>());
builder.Services.AddPouryaKitObservability();

A Host's exporter listens to the Kit's source and meter, as the service defaults' OpenTelemetry does:

.AddMeter(OperationTelemetry.SourceName, ChatClientSource)
.AddSource(
    builder.Environment.ApplicationName,
    OperationTelemetry.SourceName,
    NpgsqlSource,
    ChatClientSource
)

What you get

  • One activity and one duration per Operation, with nothing to change in Feature code.
  • One trace from an Operation into every delivery it causes, in its Host or in another.
  • No exporter and no OpenTelemetry package in the Kit.
  • Nothing allocated per dispatch while nothing listens.

Every Host in the trace registers it. A Host that never calls it emits nothing from the Kit and its deliveries have no activity, so a receiving Host calls it too, or the trace stops at its door.

Learn more

On this page