A practical guide to integrating OpenTelemetry with Event Sourcing using Marten in .NET. Covers the concepts of correlation and causation in distributed systems, then walks through concrete code for instrumenting command handling with activities and spans, propagating telemetry context into Marten document session metadata (CorrelationId, CausationId, custom headers), and carrying that context forward through event-driven processing via a MartenEventPublisher and in-memory EventBus. Includes a reusable ActivityScope wrapper and explains how to extract parent context from event metadata to maintain full trace continuity across async event handlers.
Table of contents
What’s Open Telemetry?How to do it in practice?How to propagate telemetry in Event-Driven processing?Further steps1 Impression