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

eth message type metrics #8245

Closed
Rjected opened this issue May 14, 2024 · 2 comments · Fixed by #8319
Closed

eth message type metrics #8245

Rjected opened this issue May 14, 2024 · 2 comments · Fixed by #8319
Labels
A-devp2p Related to the Ethereum P2P protocol A-networking Related to networking in general A-observability Related to tracing, metrics, logs and other observability tools C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@Rjected
Copy link
Member

Rjected commented May 14, 2024

Describe the feature

Even if we don't handle a certain type of request, it would be interesting to see what kinds of requests we are receiving, and in what proportion (GetReceipts, GetBlockHeaders, ...). We should add metrics for this.

This would involve introducing a new metrics type with counts for each type of eth message, and then increment the counts here:

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.get_mut();
let maybe_more_incoming_requests = poll_nested_stream_with_budget!(
"net::eth",
"Incoming eth requests stream",
DEFAULT_BUDGET_TRY_DRAIN_STREAM,
this.incoming_requests.poll_next_unpin(cx),
|incoming| {
match incoming {
IncomingEthRequest::GetBlockHeaders { peer_id, request, response } => {
this.on_headers_request(peer_id, request, response)
}
IncomingEthRequest::GetBlockBodies { peer_id, request, response } => {
this.on_bodies_request(peer_id, request, response)
}
IncomingEthRequest::GetNodeData { .. } => {}
IncomingEthRequest::GetReceipts { peer_id, request, response } => {
this.on_receipts_request(peer_id, request, response)
}
}
},
);

Additional context

No response

@Rjected Rjected added C-enhancement New feature or request A-devp2p Related to the Ethereum P2P protocol A-observability Related to tracing, metrics, logs and other observability tools A-networking Related to networking in general D-good-first-issue Nice and easy! A great choice to get started labels May 14, 2024
@vcshih
Copy link
Contributor

vcshih commented May 19, 2024

I'm interested in taking this one on but i noticed there's already a EthRequestHandlerMetrics here:

#[derive(Metrics)]
#[metrics(scope = "network")]
pub struct EthRequestHandlerMetrics {
/// Number of received headers requests
pub(crate) received_headers_requests: Counter,
/// Number of received bodies requests
pub(crate) received_bodies_requests: Counter,
}
which increments headers and bodies here:
fn on_headers_request(
&self,
_peer_id: PeerId,
request: GetBlockHeaders,
response: oneshot::Sender<RequestResult<BlockHeaders>>,
) {
self.metrics.received_headers_requests.increment(1);
let headers = self.get_headers_response(request);
let _ = response.send(Ok(BlockHeaders(headers)));
}
fn on_bodies_request(
&self,
_peer_id: PeerId,
request: GetBlockBodies,
response: oneshot::Sender<RequestResult<BlockBodies>>,
) {
self.metrics.received_bodies_requests.increment(1);
let mut bodies = Vec::new();
let mut total_bytes = 0;
for hash in request.0 {
if let Some(block) = self.client.block_by_hash(hash).unwrap_or_default() {
let body = BlockBody {
transactions: block.body,
ommers: block.ommers,
withdrawals: block.withdrawals,
};
total_bytes += body.length();
bodies.push(body);
if bodies.len() >= MAX_BODIES_SERVE {
break
}
if total_bytes > SOFT_RESPONSE_LIMIT {
break
}
} else {
break
}
}
let _ = response.send(Ok(BlockBodies(bodies)));
}
. I can just extend it for the other two request types but wanted to make sure that that is the intended behavior.

(edit: ala f997f5a)

@Rjected
Copy link
Member Author

Rjected commented May 19, 2024

. I can just extend it for the other two request types but wanted to make sure that that is the intended behavior.

yep, exactly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-devp2p Related to the Ethereum P2P protocol A-networking Related to networking in general A-observability Related to tracing, metrics, logs and other observability tools C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants