DistributedEventBusModules (e.g. like the RabbitMqDistributedEventBusModule) do not cause TraceId to be set in System.Diagnostics.Activity.CurrentActivity. Serilog messages are never logged with a TraceId because of that
2026-01-28 08:16:38.120 +01:00 [INF] (TraceId/CorrelationId: ) CannotBeHandledEto event received: AbpIssueRabbitMqTraceIdNotLogged.Services.Etos.CannotBeHandledEto
2026-01-28 08:16:38.350 +01:00 [WRN] (TraceId/CorrelationId: ) Exception of type 'Volo.Abp.BusinessException' was thrown.
Volo.Abp.BusinessException: Exception of type 'Volo.Abp.BusinessException' was thrown.
at AbpIssueRabbitMqTraceIdNotLogged.Services.MyDistributedEventHandler.HandleEventAsync(CannotBeHandledEto eventData) in C:\Users\ANH\source\repos\CSFiddle\AbpIssueRabbitMqTraceIdNotLogged\AbpIssueRabbitMqTraceIdNotLogged\Services\MyDistributedEventHandler.cs:line 69
at Volo.Abp.EventBus.DistributedEventHandlerMethodExecutor`1.<>c.<get_ExecutorAsync>b__1_0(IEventHandler target, Object parameter)
at Volo.Abp.EventBus.EventHandlerInvoker.InvokeAsync(IEventHandler eventHandler, Object eventData, Type eventType)
at Volo.Abp.EventBus.EventBusBase.TriggerHandlerAsync(IEventHandlerFactory asyncHandlerFactory, Type eventType, Object eventData, List`1 exceptions, InboxConfig inboxConfig)
at System.AbpExceptionExtensions.ReThrow(Exception exception)
at Volo.Abp.EventBus.EventBusBase.ThrowOriginalExceptions(Type eventType, List`1 exceptions)
at Volo.Abp.EventBus.EventBusBase.TriggerHandlersAsync(Type eventType, Object eventData)
at Volo.Abp.EventBus.Distributed.DistributedEventBusBase.TriggerHandlersDirectAsync(Type eventType, Object eventData)
at Volo.Abp.EventBus.RabbitMq.RabbitMqDistributedEventBus.ProcessEventAsync(IChannel channel, BasicDeliverEventArgs ea)
at Volo.Abp.RabbitMQ.RabbitMqMessageConsumer.HandleIncomingMessageAsync(Object sender, BasicDeliverEventArgs basicDeliverEventArgs)
2026-01-28 08:16:38.351 +01:00 [WRN] (TraceId/CorrelationId: ) Code:Insert magic reason here
2026-01-28 08:16:38.459 +01:00 [ERR] (TraceId/CorrelationId: ) This ETO cannot be deserialized.
System.InvalidOperationException: This ETO cannot be deserialized.
at AbpIssueRabbitMqTraceIdNotLogged.Services.Etos.NotDeserializableEto..ctor() in C:\Users\ANH\source\repos\CSFiddle\AbpIssueRabbitMqTraceIdNotLogged\AbpIssueRabbitMqTraceIdNotLogged\Services\Etos\NotDeserializableEto.cs:line 16
at .ctor()
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsObject(Utf8JsonReader& reader, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadFromSpanAsObject(ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
at System.Text.Json.JsonSerializer.ReadFromSpanAsObject(ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)
at Volo.Abp.Json.SystemTextJson.AbpSystemTextJsonSerializer.Deserialize(Type type, String jsonString, Boolean camelCase)
at Volo.Abp.RabbitMQ.Utf8JsonRabbitMqSerializer.Deserialize(Byte[] value, Type type)
at Volo.Abp.EventBus.RabbitMq.RabbitMqDistributedEventBus.ProcessEventAsync(IChannel channel, BasicDeliverEventArgs ea)
at Volo.Abp.RabbitMQ.RabbitMqMessageConsumer.HandleIncomingMessageAsync(Object sender, BasicDeliverEventArgs basicDeliverEventArgs)
Is there an existing issue for this?
Description
DistributedEventBusModules (e.g. like the RabbitMqDistributedEventBusModule) do not cause
TraceIdto be set in System.Diagnostics.Activity.CurrentActivity. Serilog messages are never logged with aTraceIdbecause of thatSee
but never via Activity.SetParentId
TraceIdfrom System.Diagnostics.Activity.CurrentActivity - see Logger.cs#L443Reproduction Steps
(Skip to step 7. when checking out repository https://github.com/a-herbst/AbpIssueRabbitMqTraceIdNotLogged)
Initialize solution
confiugre
appsettings.jsonappsettings.json
configure log message template to contain a
{TraceId}place holderProgram.cs
add Eto classes
add DistributedEventHandler
MyDistributedEventHandler.cs
add a HostedService publishing those messages
MyHostedService.cs
launch RabbitMq on localhost, i.e.
-> TraceId in log messages from EventHandler not set
Expected behavior
{TraceId}placeholder should produce log entries where this placeholder is replaced with thecorrelation_idvalue received from the amqp messageActual behavior
{TraceId}placeholder of the log message template string is always empty - even when the amqp message contained a correlation_id propertyRegression?
No response
Known Workarounds
System.Diagnostics.Activity.TraceIdbefore logging messages:Version
10.0
User Interface
Common (Default)
Database Provider
None/Others
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
No response