ZeroAlloc.EventSourcing.Telemetry 1.6.4

dotnet add package ZeroAlloc.EventSourcing.Telemetry --version 1.6.4
                    
NuGet\Install-Package ZeroAlloc.EventSourcing.Telemetry -Version 1.6.4
                    
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="ZeroAlloc.EventSourcing.Telemetry" Version="1.6.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZeroAlloc.EventSourcing.Telemetry" Version="1.6.4" />
                    
Directory.Packages.props
<PackageReference Include="ZeroAlloc.EventSourcing.Telemetry" />
                    
Project file
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 ZeroAlloc.EventSourcing.Telemetry --version 1.6.4
                    
#r "nuget: ZeroAlloc.EventSourcing.Telemetry, 1.6.4"
                    
#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 ZeroAlloc.EventSourcing.Telemetry@1.6.4
                    
#: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=ZeroAlloc.EventSourcing.Telemetry&version=1.6.4
                    
Install as a Cake Addin
#tool nuget:?package=ZeroAlloc.EventSourcing.Telemetry&version=1.6.4
                    
Install as a Cake Tool

ZeroAlloc.EventSourcing

NuGet Build License: MIT AOT GitHub Sponsors

Event sourcing for .NET with source-generated aggregates: appends allocate nothing of their own, there is no reflection, and it runs under NativeAOT.

Why ZeroAlloc.EventSourcing

  • No allocation on the write path. EventStore.AppendAsync and AggregateRepository.SaveAsync allocate 0 B of their own, asserted by exact-budget tests. A full stream read costs 96 B per call and nothing per event.
  • Works under NativeAOT and trimming. Aggregate event dispatch and the event type registry are generated at compile time. CI publishes and runs an AOT app for the core and for every storage adapter.
  • Compile-time diagnostics. The generator tells you when an aggregate or projection cannot be generated, instead of it silently doing nothing at runtime.
  • Tested against real databases. SQL Server and PostgreSQL run through Testcontainers, SQLite in-process, with optimistic concurrency checked inside the transaction.

Install

dotnet add package ZeroAlloc.EventSourcing.Aggregates
dotnet add package ZeroAlloc.EventSourcing.Generators
dotnet add package ZeroAlloc.EventSourcing.InMemory

The generator package emits the aggregate dispatch. The AOT-safe event serialiser comes from ZeroAlloc.Serialisation, which the core package brings in.

Quick start

using System.Text.Json.Serialization;
using Microsoft.Extensions.DependencyInjection;
using ZeroAlloc.EventSourcing;
using ZeroAlloc.EventSourcing.Aggregates;
using ZeroAlloc.EventSourcing.InMemory;
using ZeroAlloc.Serialisation;

var services = new ServiceCollection()
    .AddOrderPlacedSerializer().AddItemAddedSerializer().AddSerializerDispatcher()
    .AddSingleton<IEventTypeRegistry, OrderEventTypeRegistry>(); // emitted by the generator
services.AddEventSourcing()
    .UseInMemoryEventStore() // or UsePostgreSqlEventStore, UseSqlServerEventStore, UseSqliteEventStore
    .UseAggregateRepository<Order, OrderId>(() => new Order(), id => new StreamId($"order-{id.Value}"));
await using var provider = services.BuildServiceProvider();
var orders = provider.GetRequiredService<IAggregateRepository<Order, OrderId>>();

var id = new OrderId(Guid.NewGuid());
using (var order = new Order())
{
    order.Place("alice");
    order.AddItem(9.95m);
    await orders.SaveAsync(order, id); // appends two events, checks the expected version
}

using var loaded = (await orders.LoadAsync(id)).Value; // replays the stream
Console.WriteLine($"{loaded.State.Items} item, total {loaded.State.Total}"); // 1 item, total 9.95

[ZeroAllocSerializable(SerializationFormat.SystemTextJson)] public sealed record OrderPlaced(string Customer);
[ZeroAllocSerializable(SerializationFormat.SystemTextJson)] public sealed record ItemAdded(decimal Price);
[JsonSerializable(typeof(OrderPlaced))]
[JsonSerializable(typeof(ItemAdded))]
internal sealed partial class OrderJson : JsonSerializerContext;

public readonly record struct OrderId(Guid Value);

public partial struct OrderState : IAggregateState<OrderState>
{
    public static OrderState Initial => default;
    public int Items { get; private set; }
    public decimal Total { get; private set; }

    internal OrderState Apply(OrderPlaced e) => this;
    internal OrderState Apply(ItemAdded e) => this with { Items = Items + 1, Total = Total + e.Price };
}

// ApplyEvent dispatch and OrderEventTypeRegistry are source-generated: no reflection.
public sealed partial class Order : Aggregate<OrderId, OrderState>
{
    public void Place(string customer) => Raise(new OrderPlaced(customer));
    public void AddItem(decimal price) => Raise(new ItemAdded(price));
}

The feature tour shows consumers, projections, snapshots, Kafka and telemetry with one example each.

What you get

  • Append-only event store with optimistic concurrency through a typed StreamPosition, and a global stream across all aggregates.
  • Aggregates with struct state, generated event dispatch and a repository that loads and saves them.
  • Projections with filtering, batching and replayable rebuilds.
  • Snapshots with configurable policies, so loads replay only the newer events.
  • Stream consumers with checkpoints, batching, retry with backoff and FailFast, Skip or DeadLetter error handling.
  • Event upcasting, dead-letter stores and health checks.
  • Every package targets net8.0, net9.0 and net10.0.

Optional packages:

Performance

Against a hand-rolled SQLite event store on the same connection, both transactional, both checking the stream version inside the transaction. .NET 8.0.26, i9-12900HK, BenchmarkDotNet v0.15.8.

Operation Hand-rolled ZA.EventSourcing Overhead
Append 1 event (transactional, OCC check) 80.7 µs / 3.80 KB 106.3 µs / 4.79 KB +33% time, +26% alloc
Read 100-event stream (ordered) 66.0 µs / 11.95 KB 140.9 µs / 25.23 KB +114% time, +111% alloc

The overhead is the price of typed events, pluggable serialisation, optimistic concurrency and the aggregate, projection and snapshot layers; at real-database latency the SQL round trip dominates. Full methodology and the per-call allocation budgets: docs/performance.md.

Learn more

Product 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.

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.6.4 73 10/16/2026
1.6.3 124 10/15/2026
1.6.2 167 10/11/2026
1.6.1 103 10/11/2026
1.6.0 86 10/10/2026
1.5.0 119 10/10/2026
1.4.0 167 9/30/2026
1.3.1 156 9/30/2026
1.3.0 105 9/28/2026
1.2.5 142 9/26/2026
1.2.4 126 9/20/2026
1.2.3 91 9/20/2026
1.2.2 90 9/20/2026
1.2.1 98 9/19/2026
1.0.0 151 4/29/2026