Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[network-rpc] structure network rpc request log. #2368

Merged
merged 1 commit into from
Apr 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions network-p2p/src/request_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ impl RequestResponsesBehaviour {
(protocol_name.to_string().into(), request_id).into(),
(Instant::now(), pending_response),
);
info!(
"[network-p2p] req-resp send request {} {} {} {}",
info!(target:"network-rpc-client",
"{} {} {} {}",
request_id, target, protocol_name, len,
);
debug_assert!(prev_req_id.is_none(), "Expect request id to be unique.");
Expand Down Expand Up @@ -581,22 +581,18 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
},
..
} => {
let (started, delivered) = match self
let (started, delivered, response_len) = match self
.pending_requests
.remove(&(protocol.clone(), request_id).into())
{
Some((started, pending_response)) => {
if let Ok(response) = &response {
info!(
"[network-p2p] req-resp received response {} {}",
request_id,
response.len()
);
};
let response_len =
response.as_ref().map(|resp| resp.len()).unwrap_or(0);
let delivered = pending_response
.send(response.map_err(|()| RequestFailure::Refused))
.map_err(|_| RequestFailure::Obsolete);
(started, delivered)

(started, delivered, response_len)
}
None => {
log::warn!(
Expand All @@ -609,6 +605,16 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
}
};

info!(target:
"network-rpc-client",
"{} {} {} {} {}",
request_id,
protocol,
response_len,
delivered.is_ok(),
started.elapsed().as_millis(),
);

let out = Event::RequestFinished {
peer,
protocol: protocol.clone(),
Expand Down