diff --git a/src/Marten/DocumentStore.cs b/src/Marten/DocumentStore.cs index c8c31b888a..b3e35b3c1e 100644 --- a/src/Marten/DocumentStore.cs +++ b/src/Marten/DocumentStore.cs @@ -1,6 +1,7 @@ #nullable enable using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -524,6 +525,9 @@ private IDocumentSession openSession(SessionOptions options) _ => throw new ArgumentOutOfRangeException(nameof(SessionOptions.Tracking)) }; + session.CorrelationId = Activity.Current?.RootId; + session.CausationId = Activity.Current?.ParentId; + return session; } diff --git a/src/Marten/ISessionFactory.cs b/src/Marten/ISessionFactory.cs index 6f94e324ea..cd04907828 100644 --- a/src/Marten/ISessionFactory.cs +++ b/src/Marten/ISessionFactory.cs @@ -43,9 +43,6 @@ public IDocumentSession OpenSession() { var documentSession = _store.OpenSession(BuildOptions()); - documentSession.CorrelationId = Activity.Current?.RootId; - documentSession.CausationId = Activity.Current?.ParentId; - ApplyMetadata(documentSession); return documentSession; }