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

feat(middleware): create a generic middleware to collect method metrics. #804

Open
wants to merge 9 commits into
base: feat/v0.4
Choose a base branch
from

Conversation

andysim3d
Copy link
Collaborator

@andysim3d andysim3d commented Sep 19, 2024

[Closes/Fixes] #787

Proposed Changes

@andysim3d andysim3d marked this pull request as ready for review September 23, 2024 19:17
crates/task/src/metriclayer.rs Outdated Show resolved Hide resolved
crates/task/src/metriclayer.rs Outdated Show resolved Hide resolved
crates/task/src/metriclayer.rs Outdated Show resolved Hide resolved
crates/rpc/src/task.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@dancoombs dancoombs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also be able to implement this for Alloy in the provider crate

@andysim3d
Copy link
Collaborator Author

You should also be able to implement this for Alloy in the provider crate

yup I will do that in other pr. git won't allow me to split commits into multiple prs.

@dancoombs
Copy link
Collaborator

You should also be able to implement this for Alloy in the provider crate

yup I will do that in other pr. git won't allow me to split commits into multiple prs.

What do you mean? You should be able to add it to this PR?

@andysim3d
Copy link
Collaborator Author

You should also be able to implement this for Alloy in the provider crate

yup I will do that in other pr. git won't allow me to split commits into multiple prs.

What do you mean? You should be able to add it to this PR?

I can - but prefer small prs.

}
_ => {
// can't extract method name for batch.
"unknown".to_string()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets call this "batch"

use jsonrpsee::types::Request;
use rundler_types::task::traits::RequestExtractor;

#[derive(Copy)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You likely need to derive Clone here as well

}
}

impl<S, T, Request> Service<Request> for MetricsMiddleware<S, T, Request>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A feature that I'm realizing now that this is missing is related to response codes. Our existing ethers based metrics layer would extract those:

let http = match http_code {

Lets do this in a follow up, but we may need to also add a ResponseExtractor that can get the code out and then have that be part of the metrics.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind creating a follow up ticket and assigning it to milestone v0.4 and yourself?

@dancoombs
Copy link
Collaborator

Few last comments, but other than that LGTM! Will ✅ after the small updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants