Skip to content

2.2.0

Choose a tag to compare

@Adiakys Adiakys released this 01 Nov 14:33
91caaa4

Tracing and metrics

AnyMediator now emits OpenTelemetry-compatible spans and a duration histogram through .NET's own ActivitySource and Meter. No new dependency, no behavior change, and nothing is recorded until you subscribe:

builder.Services.AddOpenTelemetry()
    .WithTracing(t => t.AddSource(AnyMediatorDiagnostics.ActivitySourceName))
    .WithMetrics(m => m.AddMeter(AnyMediatorDiagnostics.MeterName));
  • Spans: send {Request}, create_stream {Request} (open until the stream is read, fails or is abandoned), publish {Notification} with one handle {Notification} child per handler. Attributes anymediator.operation, anymediator.message.type, anymediator.handler.type; failures set Error status, error.type and an exception event.
  • Metric: anymediator.operation.duration histogram, in seconds, by operation, message type and error.type.
  • New: AnyMediatorDiagnostics.ActivitySourceName and AnyMediatorDiagnostics.MeterName.

Cost

Not listening Listening
Send (1 span) 87 ns, 96 B 564 ns, 704 B
Publish, 3 handlers (4 spans) 307 ns, 632 B 2,310 ns, 2,872 B

Guide: Tracing and metrics

What's Changed

  • OpenTelemetry tracing and metrics for Send, CreateStream, Publish and handlers by @Adiakys in #19

Full Changelog: 2.1.1...2.2.0