Crates.io | jfrs |
lib.rs | jfrs |
version | 0.2.5 |
source | src |
created_at | 2022-09-04 08:01:36.315555 |
updated_at | 2023-10-18 10:35:32.200604 |
description | Java Flight Recorder reader for Rust |
homepage | |
repository | https://github.com/ocadaruma/jfrs |
max_upload_size | |
id | 658172 |
size | 86,253 |
Java Flight Recorder reader for Rust
fn main() {
let mut reader = JfrReader::new(File::open("/path/to/recording.jfr").unwrap());
for (reader, chunk) in reader.chunks().flatten() {
for event in reader.events(&chunk)
.flatten()
.filter(|e| e.class.name() == "jdk.ExecutionSample")
{
let thread_name = event.value()
.get_field("sampledThread")
.and_then(|v| v.get_field("osName"))
.and_then(|v| <&str>::try_from(v.value).ok())
.unwrap();
println!("sampled thread: {}", thread_name);
}
}
}
Note As of now, deserialization performance is very poor. See tuning_notes.md for the details.
Though low-level API provides full functionality to interpret the events as you need, usually we want to map known JFR events to the Rust structure.
jfrs
also provides serde-rs
based deserialization feature.
fn main() {
let mut reader = JfrReader::new(File::open("/path/to/recording.jfr").unwrap());
for (mut reader, chunk) in reader.chunks().flatten() {
for event in reader.events(&chunk)
.flatten()
.filter(|e| e.class.name() == "jdk.ExecutionSample")
{
let sample: ExecutionSample = from_event(&event).unwrap();
println!("sampled thread: {}", sample.sampled_thread.and_then(|t| t.os_name).unwrap());
}
}
}