diff --git a/core/capabilities/remote/target/client.go b/core/capabilities/remote/target/client.go index dbb7c2f8bd8..5b65bf63e44 100644 --- a/core/capabilities/remote/target/client.go +++ b/core/capabilities/remote/target/client.go @@ -42,7 +42,7 @@ var _ services.Service = &client{} func NewClient(remoteCapabilityInfo commoncap.CapabilityInfo, localDonInfo commoncap.DON, dispatcher types.Dispatcher, requestTimeout time.Duration, lggr logger.Logger) *client { return &client{ - lggr: lggr, + lggr: lggr.Named("TargetClient"), remoteCapabilityInfo: remoteCapabilityInfo, localDONInfo: localDonInfo, dispatcher: dispatcher, @@ -130,6 +130,8 @@ func (c *client) Execute(ctx context.Context, capReq commoncap.CapabilityRequest return nil, fmt.Errorf("failed to get message ID for request: %w", err) } + c.lggr.Debugw("executing remote target", "messageID", messageID) + if _, ok := c.messageIDToCallerRequest[messageID]; ok { return nil, fmt.Errorf("request for message ID %s already exists", messageID) } @@ -151,6 +153,8 @@ func (c *client) Receive(ctx context.Context, msg *types.MessageBody) { messageID := GetMessageID(msg) + c.lggr.Debugw("Remote client target receiving message", "messageID", messageID) + req := c.messageIDToCallerRequest[messageID] if req == nil { c.lggr.Warnw("received response for unknown message ID ", "messageID", messageID) diff --git a/core/capabilities/remote/target/request/client_request.go b/core/capabilities/remote/target/request/client_request.go index b48aa28207a..f1839ca8bdd 100644 --- a/core/capabilities/remote/target/request/client_request.go +++ b/core/capabilities/remote/target/request/client_request.go @@ -27,6 +27,7 @@ type ClientRequest struct { responseIDCount map[[32]byte]int errorCount map[string]int responseReceived map[p2ptypes.PeerID]bool + lggr logger.Logger requiredIdenticalResponses int @@ -99,6 +100,7 @@ func NewClientRequest(ctx context.Context, lggr logger.Logger, req commoncap.Cap responseReceived: responseReceived, responseCh: make(chan commoncap.CapabilityResponse, 1), wg: wg, + lggr: lggr, }, nil } @@ -129,6 +131,8 @@ func (c *ClientRequest) OnMessage(_ context.Context, msg *types.MessageBody) err return fmt.Errorf("sender missing from message") } + c.lggr.Debugw("OnMessage called for client request", "messageID", msg.MessageId) + sender := remote.ToPeerID(msg.Sender) received, expected := c.responseReceived[sender] diff --git a/core/capabilities/remote/target/request/server_request.go b/core/capabilities/remote/target/request/server_request.go index 25d88d2192a..0596374903b 100644 --- a/core/capabilities/remote/target/request/server_request.go +++ b/core/capabilities/remote/target/request/server_request.go @@ -62,7 +62,7 @@ func NewServerRequest(capability capabilities.TargetCapability, capabilityID str callingDon: callingDon, requestMessageID: requestMessageID, requestTimeout: requestTimeout, - lggr: lggr, + lggr: lggr.Named("ServerRequest"), } } @@ -79,6 +79,7 @@ func (e *ServerRequest) OnMessage(ctx context.Context, msg *types.MessageBody) e return fmt.Errorf("failed to add requester to request: %w", err) } + e.lggr.Debugw("OnMessage called for request", "msgId", msg.MessageId, "calls", len(e.requesters), "hasResponse", e.response != nil) if e.minimumRequiredRequestsReceived() && !e.hasResponse() { if err := e.executeRequest(ctx, msg.Payload); err != nil { e.setError(types.Error_INTERNAL_ERROR, err.Error()) @@ -216,7 +217,7 @@ func (e *ServerRequest) sendResponse(requester p2ptypes.PeerID) error { responseMsg.Payload = e.response.response } - e.lggr.Debugw("Sending response", "receiver", requester) + e.lggr.Debugw("Sending response", "receiver", requester, "msgId", e.requestMessageID) if err := e.dispatcher.Send(requester, &responseMsg); err != nil { return fmt.Errorf("failed to send response to dispatcher: %w", err) } diff --git a/core/capabilities/remote/target/server.go b/core/capabilities/remote/target/server.go index 1453cfc3778..086be15f270 100644 --- a/core/capabilities/remote/target/server.go +++ b/core/capabilities/remote/target/server.go @@ -56,7 +56,7 @@ func NewServer(peerID p2ptypes.PeerID, underlying commoncap.TargetCapability, ca requestIDToRequest: map[string]*request.ServerRequest{}, requestTimeout: requestTimeout, - lggr: lggr, + lggr: lggr.Named("TargetServer"), stopCh: make(services.StopChan), } } @@ -110,6 +110,7 @@ func (r *server) Receive(ctx context.Context, msg *types.MessageBody) { r.receiveLock.Lock() defer r.receiveLock.Unlock() + r.lggr.Debugw("received request for msg", "msgId", msg.MessageId) if msg.Method != types.MethodExecute { r.lggr.Errorw("received request for unsupported method type", "method", msg.Method) return