XForge.MediatR.OpenTelemetry
1.0.7
dotnet add package XForge.MediatR.OpenTelemetry --version 1.0.7
NuGet\Install-Package XForge.MediatR.OpenTelemetry -Version 1.0.7
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XForge.MediatR.OpenTelemetry" Version="1.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XForge.MediatR.OpenTelemetry" Version="1.0.7" />
<PackageReference Include="XForge.MediatR.OpenTelemetry" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XForge.MediatR.OpenTelemetry --version 1.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: XForge.MediatR.OpenTelemetry, 1.0.7"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package XForge.MediatR.OpenTelemetry@1.0.7
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XForge.MediatR.OpenTelemetry&version=1.0.7
#tool nuget:?package=XForge.MediatR.OpenTelemetry&version=1.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
XForge.MediatR
![]()
Simple, fluent, in-process mediator for .NET with CQRS, pipeline behaviors, and local events.
Why XForge.MediatR?
A modern alternative to MediatR with explicit CQRS, ValueTask contracts, behavior ordering, built-in resilience, and TestableMediator — all under MIT license.
| Feature | XForge.MediatR | MediatR |
|---|---|---|
ValueTask on contracts |
✅ | ❌ |
Explicit CQRS (ICommand, IQuery) |
✅ | ❌ |
| Behavior ordering & filtering | ✅ | ❌ |
TestableMediator (no DI) |
✅ | ❌ |
Result<T> monad |
✅ | ❌ |
| Retry + Circuit Breaker + Rate Limiter | ✅ | ❌ |
| Roslyn analyzer | ✅ | ❌ |
| OpenTelemetry package | ✅ | ❌ |
| Source generator for handlers | ✅ | ❌ |
| MIT license (no license key) | ✅ | ❌ |
Quick Start
dotnet add package XForge.MediatR.DependencyInjection
// 1. Define a query
public record GetOrder(int OrderId) : IQuery<OrderDto>;
public record OrderDto(int Id, string Customer, decimal Total);
// 2. Implement the handler
public class GetOrderHandler : IRequestHandler<GetOrder, OrderDto>
{
public ValueTask<OrderDto> Handle(GetOrder request, CancellationToken ct)
=> ValueTask.FromResult(new OrderDto(request.OrderId, "Acme Corp", 250.00m));
}
// 3. Register and use
builder.Services.AddXForgeMediator(cfg =>
{
cfg.RegisterHandlersFrom<Program>();
cfg.UseDefaults(); // Validation + Logging + Metrics
});
app.MapGet("/orders/{id}", async (int id, IXForgeMediator mediator) =>
Results.Ok(await mediator.Send(new GetOrder(id))));
Packages
| Package | Description | Dependencies |
|---|---|---|
XForge.MediatR |
Core mediator + pipeline + behaviors | DI.Abstractions, Logging.Abstractions |
XForge.MediatR.Abstractions |
Contracts and interfaces (zero dependencies) | None |
XForge.MediatR.DependencyInjection |
DI extensions + fluent configuration API | DI.Abstractions |
XForge.MediatR.Testing |
TestableMediator for unit tests without DI |
None (Abstractions only) |
XForge.MediatR.SourceGenerators |
Compile-time handler discovery + Roslyn analyzer | None (netstandard2.0) |
XForge.MediatR.OpenTelemetry |
Traces + metrics via OpenTelemetry | OpenTelemetry |
XForge.MediatR.AspNetCore |
ASP.NET Core integration (model binding) | AspNetCore.Mvc.Core |
XForge.MediatR.Validation |
FluentValidation adapter | FluentValidation |
XForge.MediatR.EntityFrameworkCore |
EF Core transaction behavior | EntityFrameworkCore |
XForge.MediatR.Outbox |
Outbox pattern for deferred event publishing | None (Abstractions only) |
Key Features
- CQRS Explícito —
ICommand<T>,IQuery<T>,IEventwith semantic separation - Flat Pipeline — behaviors with explicit ordering (
IOrdered) and filtering (UseFor<T>,UseWhen) - Built-in Behaviors — validation, logging, metrics, retry, circuit breaker, rate limiter, concurrency limiter, exception handling, pre/post processors
- Result<T> — typed success/failure without exceptions
- Streaming —
IStreamRequest<T>withIAsyncEnumerable<T>and pipeline support - TestableMediator — builder pattern for testing without DI container
- Source Generator — compile-time handler registration, zero reflection at startup
- Roslyn Analyzer —
XFMR001(duplicate handler),XFMR002(void mismatch),XFMR003(event handler return type) - OpenTelemetry — vendor-agnostic traces and metrics
- Multi-TFM — targets
net8.0,net9.0,net10.0
Built-in Behaviors
| Behavior | Order | Description |
|---|---|---|
ConcurrencyLimiter |
-325 | SemaphoreSlim concurrency control |
RateLimiter |
-320 | Fixed-window rate limiting |
CircuitBreaker |
-310 | Opens circuit after consecutive failures |
Retry |
-300 | Exponential/linear/constant backoff |
Authorization |
-280 | Handler-level authorization checks |
Idempotency |
-290 | Idempotent request processing |
MultiTenant |
-260 | Tenant validation |
ExceptionHandling |
-250 | Typed exception handlers |
Validation |
-200 | FluentValidation integration |
PrePostProcessors |
-150 | Pre/post handler hooks |
Logging |
-100 | High-performance structured logging |
Diagnostics |
-75 | Activity enrichment |
PerformanceMetrics |
-50 | Duration measurement + Activity spans |
Audit |
-40 | Audit trail via IAuditSink |
Caching |
-30 | Query result caching |
Transaction |
-15 | TransactionScope for commands |
Performance
Benchmarked on .NET 10.0.8, x64 RyuJIT AVX2 against MediatR 14.1.0 and Mediator 3.0.2 (source-generator):
| Operation | XForge.MediatR | MediatR | Mediator (source-gen) |
|---|---|---|---|
| Send | 61 ns / 120 B | 72 ns / 296 B | 21 ns / 96 B |
| Publish | 161 ns / 88 B | 392 ns / 1248 B | 27 ns / 0 B |
| Pipeline (0 beh) | 79 ns / 120 B | 74 ns / 296 B | — |
| Pipeline (3 beh) | 671 ns / 1024 B | 150 ns / 608 B | — |
| Cold Start | ~6 µs | ~174 µs | ~14 µs |
Highlights:
- Send 1.18x faster than MediatR with 59% less allocation (120 B vs 296 B)
- Publish 2.43x faster than MediatR with 14x less allocation
- Cold Start 29x faster than MediatR — ideal for serverless
- Zero tracing overhead — ActivitySource short-circuits when no listeners
See Performance & Benchmarks for full details.
Documentation
- Manual (pt-br) — Complete Portuguese manual with 25 sections
- Manual (en-us) — Complete English manual
- CHANGELOG.md — Release history
- Architecture — Package dependency graph and design decisions
Requirements
| Requirement | Version |
|---|---|
| .NET SDK | 8.0+ |
| C# | 12+ |
| IDE | Visual Studio 2022 17.8+, Rider 2023.3+, or VS Code with C# extension |
License
MIT — Copyright (c) XForge
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- OpenTelemetry (>= 1.15.3)
- XForge.MediatR.Abstractions (>= 1.0.7)
-
net8.0
- OpenTelemetry (>= 1.15.3)
- XForge.MediatR.Abstractions (>= 1.0.7)
-
net9.0
- OpenTelemetry (>= 1.15.3)
- XForge.MediatR.Abstractions (>= 1.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.7 | 90 | 5/25/2026 |
| 1.0.6 | 87 | 5/25/2026 |
| 1.0.5 | 79 | 5/24/2026 |
| 1.0.4 | 82 | 5/24/2026 |
| 1.0.3 | 83 | 5/24/2026 |
| 1.0.2 | 88 | 5/24/2026 |
| 1.0.1 | 94 | 5/23/2026 |
| 1.0.0 | 85 | 5/23/2026 |
| 0.26.0 | 89 | 5/23/2026 |
| 0.25.0 | 87 | 5/23/2026 |
| 0.24.0 | 92 | 5/23/2026 |
| 0.23.0 | 97 | 5/23/2026 |
| 0.21.0 | 90 | 5/22/2026 |
| 0.20.0 | 109 | 5/22/2026 |
| 0.19.0 | 92 | 5/22/2026 |
| 0.16.0 | 79 | 5/21/2026 |
| 0.15.0 | 83 | 5/21/2026 |
| 0.14.0 | 81 | 5/21/2026 |
| 0.13.0 | 85 | 5/21/2026 |
| 0.12.0 | 85 | 5/21/2026 |
Loading failed