Skip to content

Commit

Permalink
Improving the instrumentation on the reply listener. Closes GH-1172
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Dec 17, 2024
1 parent 92f2a85 commit 4661817
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Wolverine/Runtime/RemoteInvocation/ResponseHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Concurrent;
using JasperFx.Core;
using Microsoft.Extensions.Logging;
using Wolverine.Util;

namespace Wolverine.Runtime.RemoteInvocation;

Expand Down Expand Up @@ -31,6 +32,8 @@ public Task<T> RegisterListener<T>(Envelope envelope, CancellationToken cancella
envelope.DeliverWithin = timeout; // Make the message expire so it doesn't cruft up the receivers
var listener = new ReplyListener<T>(envelope, this, timeout, cancellationToken);
_listeners.AddOrUpdate(envelope.Id, listener, (_, _) => listener);

_logger.LogDebug("Registering a reply listener for message type {MessageType} and conversation id {ConversationId}", typeof(T).ToMessageTypeName(), envelope.ConversationId);

return listener.Task;
}
Expand All @@ -49,6 +52,11 @@ public void Complete(Envelope response)
if (_listeners.TryGetValue(response.ConversationId, out var listener))
{
listener.Complete(response);
_logger.LogDebug("Successfully completed a reply listener for conversation id {ReplyId} with message type {MessageTypeName}", response.ConversationId, response.MessageType);
}
else
{
_logger.LogError("Unable to find a registered reply listener for conversation id {ReplyId} with message type {MessageType}. The listener may have previously timed out", response.ConversationId, response.MessageType);
}
}
catch (Exception e)
Expand Down

0 comments on commit 4661817

Please sign in to comment.