public Task PreConsume <T>(ConsumeContext <T> context) where T : class { var messageTypeName = context.Message.GetType().FullName; MessageContext.MessageName.Value = new MessageName(messageTypeName); var sentTime = context.GetSentTime(); LogContext.Push(new ILogEventEnricher[] { new FullMessageNameEnricher(messageTypeName), new QueueLogTypeEnricher(), new MessageBodyEnricher(context.Message), new MessageIdEnricher(context.MessageId), }); if (!sentTime.HasValue) { Logger.Information("Received message {MessageName} message without SentTime", ShortMessageName.Get(messageTypeName)); return(Task.CompletedTask); } var elapsed = (DateTime.UtcNow - sentTime.Value).TotalMilliseconds.Round(); LogContext.Push(new ILogEventEnricher[] { new SentTimeEnricher(sentTime.Value), new LatencyEnricher(elapsed), new CreatedTimeEnricher(context.Headers.GetCreatedTime()), }); Logger.Information("Message {MessageName} received after {Elapsed} ms", ShortMessageName.Get(messageTypeName), elapsed); return(Task.CompletedTask); }