-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
rpc benchmark: script to pull Grafana logs #20911
base: rpc-benchmark-init
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
async fn fetch_logs( | ||
client: &reqwest::Client, | ||
url: &str, | ||
query: &str, | ||
start: &str, | ||
end: &str, | ||
limit: u64, | ||
offset: Option<u64>, | ||
) -> Result<LokiResponse, Box<dyn Error>> { | ||
let mut params = vec![ | ||
("query".to_string(), query.to_string()), | ||
("start".to_string(), start.to_string()), | ||
("end".to_string(), end.to_string()), | ||
("limit".to_string(), limit.to_string()), | ||
]; | ||
if let Some(o) = offset { | ||
params.push(("start_from".to_string(), o.to_string())); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is mainly when we're benchmarking against a remote jsonrpc service right? if we were to benchmark jsonrpc locally, then we can pull from the local metrics service or something like that directly?
message: String, | ||
} | ||
|
||
fn extract_body_from_message(message: &str) -> Option<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add doc comments explaining the format that you are parsing here, and for fetch_logs
.
.with_env() | ||
.init(); | ||
if let Err(e) = run().await { | ||
error!("Error: {}", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error!("Error: {}", e); | |
error!("{e}"); |
let mut writer = BufWriter::new(file); | ||
|
||
for (method, bodies) in method_map { | ||
info!("Writing {} logs for method: {}", bodies.len(), method); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
info!("Writing {} logs for method: {}", bodies.len(), method); | |
info!(len=bodies.len(), method, "Writing logs"); |
let line = format!(r#"{{"method":"{}", "body":{}}}"#, method, body); | ||
writer.write_all(line.as_bytes())?; | ||
writer.write_all(b"\n")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to allocate for the line before writing it out.
let line = format!(r#"{{"method":"{}", "body":{}}}"#, method, body); | |
writer.write_all(line.as_bytes())?; | |
writer.write_all(b"\n")?; | |
write!(writer, r#"{{"method":"{method}", "body":"#)?; | |
writer.write_all(body.as_bytes())?; | |
write!(writer, "}}\n")?; |
let mut method_map: HashMap<String, Vec<String>> = HashMap::new(); | ||
for log_entry in all_logs { | ||
if let Some(body_content) = extract_body_from_message(&log_entry.message) { | ||
if let Ok(parsed) = serde_json::from_str::<Value>(&body_content) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we print an error if we weren't able to parse the JSON?
Description
a stacked pr, pull sampled JSON RPC request logs from Grafana API, now a local
port-forward
is necessary to make it workTest plan
local run
the output, suix_getBalance / suix_getAllBalances are the top ones taking the majority
logged jsonl file is like
Release notes
Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.
For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.