---
title: "Set up OpenTelemetry with Event Sourcing and Marten"
url: https://daily.dev/posts/set-up-opentelemetry-with-event-sourcing-and-marten-wzzuvcvxi
source_url: https://event-driven.io/en/set_up_opentelemetry_wtih_event_sourcing_and_marten
type: article
source: "Event-Driven by Oskar Dudycz"
published: 2026-06-17T11:26:20.450Z
updated: 2026-06-17T11:31:54.454Z
tags: ["devops", "architecture", ".net", "opentelemetry"]
reading_time: 10
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up OpenTelemetry with Event Sourcing and Marten

**[Event-Driven by Oskar Dudycz](https://daily.dev/sources/event-driven-io)** · 10 min read · 0 upvotes · 0 comments

## Summary

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.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://event-driven.io/en/set_up_opentelemetry_wtih_event_sourcing_and_marten>

## Similar posts on daily.dev

- [Distributed Tracing Across .NET Services with OpenTelemetry: W3C Trace Context and Baggage](https://daily.dev/posts/distributed-tracing-across-net-services-with-opentelemetry-w3c-trace-context-and-baggage-u8610tjrt) · We Are .NET · 1 upvotes · 0 comments
- [Logging, Metrics, and Distributed Tracing in .NET with OpenTelemetry and ClickStack](https://daily.dev/posts/logging-metrics-and-distributed-tracing-in-net-with-opentelemetry-and-clickstack-ohkhm2db1) · ClickHouse · 4 upvotes · 0 comments

---

Tags: [#devops](https://daily.dev/tags/devops), [#architecture](https://daily.dev/tags/architecture), [#.net](https://daily.dev/tags/.net), [#opentelemetry](https://daily.dev/tags/opentelemetry)

[View this post on daily.dev](https://daily.dev/posts/set-up-opentelemetry-with-event-sourcing-and-marten-wzzuvcvxi)
