diff --git a/pyroscope/pprof-bin/Cargo.toml b/pyroscope/pprof-bin/Cargo.toml index 0f481fb5..776d8439 100644 --- a/pyroscope/pprof-bin/Cargo.toml +++ b/pyroscope/pprof-bin/Cargo.toml @@ -19,6 +19,7 @@ prost = "0.12.3" json = "0.12.4" lazy_static = "1.4.0" bytemuck = "1.16.1" +flate2 = "1.0" # The `console_error_panic_hook` crate provides better debugging of panics by # logging them with `console.error`. This is great for development, but requires diff --git a/pyroscope/pprof-bin/pkg/pprof_bin_bg.wasm b/pyroscope/pprof-bin/pkg/pprof_bin_bg.wasm index b9b9c847..e754262f 100644 Binary files a/pyroscope/pprof-bin/pkg/pprof_bin_bg.wasm and b/pyroscope/pprof-bin/pkg/pprof_bin_bg.wasm differ diff --git a/pyroscope/pprof-bin/src/lib.rs b/pyroscope/pprof-bin/src/lib.rs index 02605ce0..493d3992 100644 --- a/pyroscope/pprof-bin/src/lib.rs +++ b/pyroscope/pprof-bin/src/lib.rs @@ -14,6 +14,7 @@ use pprof_pb::querier::v1::Level; use pprof_pb::querier::v1::SelectMergeStacktracesResponse; use prost::Message; use std::collections::{HashMap, HashSet}; +use std::io::Read; use std::panic; use std::sync::Mutex; use std::vec::Vec; @@ -615,8 +616,17 @@ pub fn export_trees_pprof(payload: &[u8]) -> Vec { let bin_profs = reader.read_blob_vec(); let mut merger = merge::ProfileMerge::new(); for bin_prof in bin_profs { - let mut prof = Profile::decode(bin_prof).unwrap(); - merger.merge(&mut prof); + if bin_prof.len() >= 2 && bin_prof[0] == 0x1f && bin_prof[1] == 0x8b { + let mut decompressed = Vec::new(); + let mut decoder = flate2::read::GzDecoder::new(&bin_prof[..]); + decoder.read_to_end(&mut decompressed).unwrap(); + let mut prof = Profile::decode(std::io::Cursor::new(decompressed)).unwrap(); + merger.merge(&mut prof); + }else { + let mut prof = Profile::decode(bin_prof).unwrap(); + merger.merge(&mut prof); + } + } let res = merger.profile(); res.encode_to_vec()