:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(ingestion): add continuous memory profiling via pyroscope jemalloc backend (#85563)
José Sequeira336d3703f6a6
diff --git a/rust/Cargo.lock b/rust/Cargo.lockindex 850e7e4bbebd..79418b36a860 100644--- a/rust/Cargo.lock+++ b/rust/Cargo.lock@@ -8,7 +8,7 @@ version = "0.25.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b"dependencies = [- "gimli",+ "gimli 0.32.3",][[package]]@@ -214,7 +214,7 @@ version = "0.5.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "7eb93bbb63b9c227414f6eb3a0adfddca591a8ce1e9b60661bb08969b87e340b"dependencies = [- "object",+ "object 0.37.3",][[package]]@@ -1526,7 +1526,7 @@ dependencies = ["cfg-if","libc","miniz_oxide",- "object",+ "object 0.37.3","rustc-demangle","windows-link",]@@ -2748,7 +2748,6 @@ version = "0.1.0"dependencies = ["envconfig","pyroscope",- "pyroscope_pprofrs","thiserror 2.0.18","tracing",]@@ -3518,6 +3517,12 @@ dependencies = ["syn 2.0.117",]+[[package]]+name = "dary_heap"+version = "0.3.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8b1e3a325bc115f096c8b77bbf027a7c2592230e70be2d985be950d3d5e60ebe"+[[package]]name = "dashmap"version = "5.5.3"@@ -4743,6 +4748,20 @@ version = "2.0.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "28dd6caf6059519a65843af8fe2a3ae298b14b80179855aeb4adc2c1934ee619"+[[package]]+name = "framehop"+version = "0.16.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6f54fe4785e899d4d6f43793b151c63c5647240fc630b005509d2614a939f693"+dependencies = [+ "arrayvec",+ "cfg-if",+ "fallible-iterator 0.3.0",+ "gimli 0.33.0",+ "macho-unwind-info",+ "pe-unwind-info",+]+[[package]]name = "from_variant"version = "3.0.0"@@ -4976,6 +4995,15 @@ dependencies = ["stable_deref_trait",]+[[package]]+name = "gimli"+version = "0.33.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0bf7f043f89559805f8c7cacc432749b2fa0d0a0a9ee46ce47164ed5ba7f126c"+dependencies = [+ "stable_deref_trait",+]+[[package]]name = "glob"version = "0.3.3"@@ -5969,6 +5997,7 @@ dependencies = ["axum 0.7.9","chrono","common-alloc",+ "common-continuous-profiling","dashmap 6.1.0","envconfig","flate2",@@ -6796,21 +6825,25 @@ dependencies = [[[package]]name = "libflate"-version = "1.4.0"+version = "2.3.1"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "5ff4ae71b685bbad2f2f391fe74f6b7659a34871c08b210fdc039e43bee07d18"+checksum = "a4da9b700e758e57152a1fd1c52cbdc5727c1aa6d8743dc1acda917398f1d76c"dependencies = ["adler32","crc32fast",+ "dary_heap","libflate_lz77",+ "no_std_io2",][[package]]name = "libflate_lz77"-version = "1.2.0"+version = "2.3.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "a52d3a8bfc85f250440e4424db7d857e241a3aebbbe301f3eb606ab15c39acbf"+checksum = "ff7a10e427698aef6eef269482776debfef63384d30f13aad39a1a95e0e098fd"dependencies = [+ "hashbrown 0.16.1",+ "no_std_io2","rle-decode-fast",]@@ -7060,6 +7093,17 @@ dependencies = ["libc",]+[[package]]+name = "macho-unwind-info"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bb4bdc8b0ce69932332cf76d24af69c3a155242af95c226b2ab6c2e371ed1149"+dependencies = [+ "thiserror 2.0.18",+ "zerocopy",+ "zerocopy-derive",+]+[[package]]name = "mappings"version = "0.7.2"@@ -7376,15 +7420,6 @@ version = "0.10.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084"-[[package]]-name = "names"-version = "0.14.0"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "7bddcd3bf5144b6392de80e04c347cd7fab2508f6df16a85fc496ecd5cec39bc"-dependencies = [- "rand 0.8.5",-]-[[package]]name = "native-tls"version = "0.2.18"@@ -7468,17 +7503,6 @@ dependencies = ["libc",]-[[package]]-name = "nix"-version = "0.27.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"-dependencies = [- "bitflags 2.11.0",- "cfg-if",- "libc",-]-[[package]]name = "nix"version = "0.31.3"@@ -7497,6 +7521,15 @@ version = "0.4.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c"+[[package]]+name = "no_std_io2"+version = "0.9.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "418abd1b6d34fbf6cae440dc874771b0525a604428704c76e48b29a5e67b8003"+dependencies = [+ "memchr",+]+[[package]]name = "nohash-hasher"version = "0.2.0"@@ -7854,6 +7887,17 @@ dependencies = ["memchr",]+[[package]]+name = "object"+version = "0.39.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2e5a6c098c7a3b6547378093f5cc30bc54fd361ce711e05293a5cc589562739b"+dependencies = [+ "flate2",+ "memchr",+ "ruzstd",+]+[[package]]name = "object_store"version = "0.13.2"@@ -8313,6 +8357,19 @@ dependencies = ["thiserror 1.0.69",]+[[package]]+name = "pe-unwind-info"+version = "0.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "97f6fccfd2d9d2df765ca23ff85fe5cc437fb0e6d3e164e4d3cbe09d14780c93"+dependencies = [+ "arrayvec",+ "bitflags 2.11.0",+ "thiserror 2.0.18",+ "zerocopy",+ "zerocopy-derive",+]+[[package]]name = "pem"version = "1.1.1"@@ -9000,27 +9057,7 @@ dependencies = ["protobuf-codegen","smallvec","spin 0.10.0",- "symbolic-demangle",- "tempfile",- "thiserror 2.0.18",-]--[[package]]-name = "pprof2"-version = "0.13.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "8961ed0a916b512e565f8070eb0dfa05773dd140160b45ac9a5ad339b557adeb"-dependencies = [- "backtrace",- "cfg-if",- "findshlibs",- "libc",- "log",- "nix 0.27.1",- "once_cell",- "parking_lot",- "smallvec",- "symbolic-demangle",+ "symbolic-demangle 12.17.2","tempfile","thiserror 2.0.18",]@@ -9232,16 +9269,6 @@ dependencies = ["unarray",]-[[package]]-name = "prost"-version = "0.11.9"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd"-dependencies = [- "bytes",- "prost-derive 0.11.9",-]-[[package]]name = "prost"version = "0.12.6"@@ -9313,19 +9340,6 @@ dependencies = ["tempfile",]-[[package]]-name = "prost-derive"-version = "0.11.9"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4"-dependencies = [- "anyhow",- "itertools 0.10.5",- "proc-macro2",- "quote",- "syn 1.0.109",-]-[[package]]name = "prost-derive"version = "0.12.6"@@ -9602,31 +9616,33 @@ dependencies = [[[package]]name = "pyroscope"-version = "0.5.8"+version = "2.0.6"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "d3a5f63b0d2727095db59045e6a0ef3259b28b90d481ae88f0e3d866d0234ce8"+checksum = "b6869e0f2cae5cef10281c57d5a260f91372d7f190a7f717eb1a54f643d92151"dependencies = [+ "aligned-vec",+ "backtrace",+ "findshlibs",+ "framehop",+ "jemalloc_pprof",+ "lazy_static","libc","libflate","log",- "names",- "prost 0.11.9",- "reqwest 0.12.28",+ "memmap2",+ "nix 0.26.4",+ "object 0.39.1",+ "once_cell",+ "prost 0.14.3",+ "reqwest 0.13.4","serde_json",- "thiserror 1.0.69",+ "smallvec",+ "spin 0.12.3",+ "symbolic-demangle 13.6.1",+ "tempfile",+ "thiserror 2.0.18","url",- "winapi",-]--[[package]]-name = "pyroscope_pprofrs"-version = "0.2.10"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "50da7a8950c542357de489aa9ee628f46322b1beaac1f4fa3313bcdebe85b4ea"-dependencies = [- "log",- "pprof2",- "pyroscope",+ "uuid",][[package]]@@ -10200,7 +10216,6 @@ dependencies = ["base64 0.22.1","bytes","encoding_rs",- "futures-channel","futures-core","futures-util","h2 0.4.13",@@ -10271,6 +10286,7 @@ dependencies = ["rustls-platform-verifier","serde","serde_json",+ "serde_urlencoded","sync_wrapper 1.0.2","tokio","tokio-rustls 0.26.4",@@ -10653,6 +10669,15 @@ dependencies = ["wait-timeout",]+[[package]]+name = "ruzstd"+version = "0.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a7c1c839d570d835527c9a5e4db7cb2198683a988cb9d7293fc8674e6bd58fc8"+dependencies = [+ "twox-hash",+]+[[package]]name = "ryu"version = "1.0.23"@@ -11321,6 +11346,15 @@ dependencies = ["lock_api",]+[[package]]+name = "spin"+version = "0.12.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0134f9043ed38b087ac4f7d4af44c79e2c9e5094421fe3164f435ce585953b10"+dependencies = [+ "lock_api",+]+[[package]]name = "spki"version = "0.7.3"@@ -11866,9 +11900,9 @@ version = "12.17.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3a7418e0528510cf3b289a1250775e8c8b6a333bcdd01689133f68a818da798f"dependencies = [- "symbolic-common",+ "symbolic-common 12.17.2","symbolic-debuginfo",- "symbolic-demangle",+ "symbolic-demangle 12.17.2","symbolic-sourcemapcache","symbolic-symcache",]@@ -11885,6 +11919,18 @@ dependencies = ["uuid",]+[[package]]+name = "symbolic-common"+version = "13.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ba98c95b1ff25ce40400d286f5dec838097ee42ad1bbd64242cce24c2baace8c"+dependencies = [+ "debugid",+ "memmap2",+ "stable_deref_trait",+ "uuid",+]+[[package]]name = "symbolic-debuginfo"version = "12.17.2"@@ -11896,7 +11942,7 @@ dependencies = ["elsa","fallible-iterator 0.3.0","flate2",- "gimli",+ "gimli 0.32.3","goblin","nom","nom-supreme",@@ -11909,7 +11955,7 @@ dependencies = ["serde_json","smallvec","srcsrv",- "symbolic-common",+ "symbolic-common 12.17.2","symbolic-ppdb","thiserror 2.0.18","wasmparser 0.243.0",@@ -11927,7 +11973,17 @@ dependencies = ["cpp_demangle","msvc-demangler","rustc-demangle",- "symbolic-common",+ "symbolic-common 12.17.2",+]++[[package]]+name = "symbolic-demangle"+version = "13.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1c547b0231d1794aec8e4795dbb04c1d395ff774954f18e37d46d5a70f0ce4b2"+dependencies = [+ "rustc-demangle",+ "symbolic-common 13.6.1",][[package]]@@ -11940,7 +11996,7 @@ dependencies = ["indexmap 2.13.0","serde","serde_json",- "symbolic-common",+ "symbolic-common 12.17.2","thiserror 2.0.18","uuid","watto",@@ -11955,7 +12011,7 @@ dependencies = ["itertools 0.14.0","js-source-scopes","sourcemap",- "symbolic-common",+ "symbolic-common 12.17.2","thiserror 2.0.18","tracing","watto",@@ -11968,7 +12024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9b14fe4ebcdce2b318d7b4f04d12e6c73c1504a59ed4423d90607aa7baa9ea37"dependencies = ["indexmap 2.13.0",- "symbolic-common",+ "symbolic-common 12.17.2","symbolic-debuginfo","thiserror 2.0.18","tracing",diff --git a/rust/capture/src/v1/quota_limiter_shim.rs b/rust/capture/src/v1/quota_limiter_shim.rsindex 61ae959aa6b5..d9231f19e9a1 100644--- a/rust/capture/src/v1/quota_limiter_shim.rs+++ b/rust/capture/src/v1/quota_limiter_shim.rs@@ -236,12 +236,7 @@ mod tests {http1_header_read_timeout_ms: Some(5000),body_chunk_read_timeout_ms: None,body_read_chunk_size_kb: 256,- continuous_profiling: ContinuousProfilingConfig {- continuous_profiling_enabled: false,- pyroscope_server_address: String::new(),- pyroscope_application_name: String::new(),- pyroscope_sample_rate: 100,- },+ continuous_profiling: ContinuousProfilingConfig::default(),capture_v1_sinks: String::new(),capture_v1_max_compressed_body_bytes: 10 * 1024 * 1024,capture_v1_max_decompressed_body_bytes: 50 * 1024 * 1024,diff --git a/rust/capture/tests/common/utils.rs b/rust/capture/tests/common/utils.rsindex b759184c49f7..03cf7ccfe357 100644--- a/rust/capture/tests/common/utils.rs+++ b/rust/capture/tests/common/utils.rs@@ -152,12 +152,7 @@ pub static DEFAULT_CONFIG: Lazy<Config> = Lazy::new(|| Config {http1_header_read_timeout_ms: Some(5000), // 5 seconds defaultbody_chunk_read_timeout_ms: None, // disabled by default in testsbody_read_chunk_size_kb: 256, // 256KB default- continuous_profiling: ContinuousProfilingConfig {- continuous_profiling_enabled: false,- pyroscope_server_address: String::new(),- pyroscope_application_name: String::new(),- pyroscope_sample_rate: 100,- },+ continuous_profiling: ContinuousProfilingConfig::default(),capture_v1_sinks: String::new(),capture_v1_max_compressed_body_bytes: 10 * 1024 * 1024,capture_v1_max_decompressed_body_bytes: 50 * 1024 * 1024,diff --git a/rust/common/alloc/Cargo.toml b/rust/common/alloc/Cargo.tomlindex c000c381d3c1..b713ef7aa697 100644--- a/rust/common/alloc/Cargo.toml+++ b/rust/common/alloc/Cargo.toml@@ -7,5 +7,7 @@ edition = "2021"workspace = true[dependencies]+# "profiling" compiles jemalloc's heap profiler in but leaves it inactive; it only+# runs when a deploy opts in via _RJEM_MALLOC_CONF (see common/continuous_profiling).[target.'cfg(not(target_env = "msvc"))'.dependencies]-tikv-jemallocator = "0.6"+tikv-jemallocator = { version = "0.6", features = ["profiling"] }diff --git a/rust/common/continuous_profiling/Cargo.toml b/rust/common/continuous_profiling/Cargo.tomlindex 12c530a691d9..37118695dfdb 100644--- a/rust/common/continuous_profiling/Cargo.toml+++ b/rust/common/continuous_profiling/Cargo.toml@@ -8,7 +8,6 @@ workspace = true[dependencies]envconfig = { workspace = true }-pyroscope = "0.5"-pyroscope_pprofrs = "0.2"+pyroscope = { version = "2", features = ["backend-pprof-rs", "backend-jemalloc"] }thiserror = { workspace = true }tracing = { workspace = true }diff --git a/rust/common/continuous_profiling/src/lib.rs b/rust/common/continuous_profiling/src/lib.rsindex ccfa01ae82b1..f3e1a56ff07c 100644--- a/rust/common/continuous_profiling/src/lib.rs+++ b/rust/common/continuous_profiling/src/lib.rs@@ -3,12 +3,17 @@ use std::panic;use std::sync::Once;use envconfig::Envconfig;-use pyroscope::pyroscope::PyroscopeAgentRunning;+use pyroscope::backend::jemalloc::jemalloc_backend;+use pyroscope::backend::{+ pprof_backend, BackendConfig, BackendImpl, BackendUninitialized, PprofConfig,+};+use pyroscope::pyroscope::{PyroscopeAgentBuilder, PyroscopeAgentRunning};use pyroscope::PyroscopeAgent;-use pyroscope_pprofrs::{pprof_backend, PprofConfig};static PANIC_HOOK_INSTALLED: Once = Once::new();+const SPY_NAME: &str = "pyroscope-rs";+/// K8s metadata environment variables for Pyroscope tagsconst K8S_TAG_ENV_VARS: &[(&str, &str)] = &[("namespace", "K8S_NAMESPACE"),@@ -19,7 +24,8 @@ const K8S_TAG_ENV_VARS: &[(&str, &str)] = &[("app", "K8S_APP"),("container", "K8S_CONTAINER_NAME"),("controller_type", "K8S_CONTROLLER_TYPE"),- ("service_name", "K8S_SERVICE_NAME"),+ // No service_name here: pyroscope 2.x already sets it from the application+ // name, and the server rejects profiles with a duplicate label (HTTP 400).];#[derive(Envconfig, Clone, Debug)]@@ -27,6 +33,12 @@ pub struct ContinuousProfilingConfig {#[envconfig(default = "false")]pub continuous_profiling_enabled: bool,+ /// Also push jemalloc heap profiles (profile type "memory"). Requires jemalloc+ /// profiling to be active at process start, e.g.+ /// `_RJEM_MALLOC_CONF=prof:true,prof_active:true,lg_prof_sample:19`.+ #[envconfig(default = "false")]+ pub continuous_profiling_memory_enabled: bool,+#[envconfig(default = "")]pub pyroscope_server_address: String,@@ -40,10 +52,18 @@ pub struct ContinuousProfilingConfig {/// A running Pyroscope agent handle. Keep this alive for the duration of profiling.pub type RunningAgent = PyroscopeAgent<PyroscopeAgentRunning>;+/// The running profiling agents. Keep this alive for the duration of profiling;+/// dropping it stops all profiling.+pub struct RunningAgents {+ _cpu: RunningAgent,+ _memory: Option<RunningAgent>,+}+impl Default for ContinuousProfilingConfig {fn default() -> Self {Self {continuous_profiling_enabled: false,+ continuous_profiling_memory_enabled: false,pyroscope_server_address: String::new(),pyroscope_application_name: String::new(),pyroscope_sample_rate: 100,@@ -107,8 +127,14 @@ fn install_panic_safe_hook() {impl ContinuousProfilingConfig {/// Initialize continuous profiling if enabled.///- /// Returns an `Option<RunningAgent>` that should be kept alive for the- /// duration of the application. When dropped, the agent will stop profiling.+ /// Returns an `Option<RunningAgents>` that should be kept alive for the+ /// duration of the application. When dropped, the agents will stop profiling.+ ///+ /// A CPU profiling agent is always started. When+ /// `continuous_profiling_memory_enabled` is set, a second agent pushes+ /// jemalloc heap profiles; if that agent fails to start (typically because+ /// jemalloc profiling isn't active), the error is logged and CPU profiling+ /// continues alone.////// This function installs a panic hook to ensure that panics in pyroscope's/// internal threads don't crash the main application. The pyroscope library@@ -119,10 +145,10 @@ impl ContinuousProfilingConfig {////// ```ignore/// let config = ContinuousProfilingConfig::init_from_env()?;- /// let _agent = config.start_agent()?;- /// // Agent runs until _agent is dropped+ /// let _agents = config.start_agent()?;+ /// // Agents run until _agents is dropped/// ```- pub fn start_agent(&self) -> Result<Option<RunningAgent>, ContinuousProfilingError> {+ pub fn start_agent(&self) -> Result<Option<RunningAgents>, ContinuousProfilingError> {if !self.continuous_profiling_enabled {tracing::info!("Continuous profiling is disabled");return Ok(None);@@ -145,30 +171,69 @@ impl ContinuousProfilingConfig {server_address = %self.pyroscope_server_address,app_name = %self.pyroscope_application_name,sample_rate = %self.pyroscope_sample_rate,+ memory_enabled = %self.continuous_profiling_memory_enabled,tags = ?tags,"Starting continuous profiling");+ let cpu_backend = pprof_backend(+ PprofConfig {+ sample_rate: self.pyroscope_sample_rate,+ },+ BackendConfig::default(),+ );+ let cpu = self.start_backend(cpu_backend, &tags)?;++ let memory = if self.continuous_profiling_memory_enabled {+ match self.start_backend(jemalloc_backend(), &tags) {+ Ok(agent) => Some(agent),+ Err(e) => {+ tracing::error!(+ error = %e,+ "Failed to start memory profiling agent - check that jemalloc \+ profiling is active (_RJEM_MALLOC_CONF=prof:true,prof_active:true); \+ CPU profiling continues"+ );+ None+ }+ }+ } else {+ None+ };++ tracing::info!(+ memory_profiling = %memory.is_some(),+ "Continuous profiling agent started successfully"+ );++ Ok(Some(RunningAgents {+ _cpu: cpu,+ _memory: memory,+ }))+ }++ fn start_backend(+ &self,+ backend: BackendImpl<BackendUninitialized>,+ tags: &[(String, String)],+ ) -> Result<RunningAgent, ContinuousProfilingError> {// Convert tags to the format expected by pyroscope: Vec<(&str, &str)>let tags_refs: Vec<(&str, &str)> =tags.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();- let agent = PyroscopeAgent::builder(+ let agent = PyroscopeAgentBuilder::new(&self.pyroscope_server_address,&self.pyroscope_application_name,+ self.pyroscope_sample_rate,+ SPY_NAME,+ env!("CARGO_PKG_VERSION"),+ backend,)- .backend(pprof_backend(- PprofConfig::new().sample_rate(self.pyroscope_sample_rate),- )).tags(tags_refs).build().map_err(ContinuousProfilingError::Build)?;- let agent = agent.start().map_err(ContinuousProfilingError::Start)?;-- tracing::info!("Continuous profiling agent started successfully");-- Ok(Some(agent))+ agent.start().map_err(ContinuousProfilingError::Start)}}diff --git a/rust/ingestion-consumer/Cargo.toml b/rust/ingestion-consumer/Cargo.tomlindex 2d664d7a330b..dbe9aa244c5d 100644--- a/rust/ingestion-consumer/Cargo.toml+++ b/rust/ingestion-consumer/Cargo.toml@@ -8,6 +8,7 @@ anyhow = { workspace = true }axum = { workspace = true }chrono = { workspace = true }common-alloc = { path = "../common/alloc" }+common-continuous-profiling = { path = "../common/continuous_profiling" }dashmap = { workspace = true }envconfig = { workspace = true }flate2 = { workspace = true }diff --git a/rust/ingestion-consumer/src/config.rs b/rust/ingestion-consumer/src/config.rsindex 87ea4703fc2c..a84486abf058 100644--- a/rust/ingestion-consumer/src/config.rs+++ b/rust/ingestion-consumer/src/config.rs@@ -1,3 +1,4 @@+use common_continuous_profiling::ContinuousProfilingConfig;use envconfig::Envconfig;use rdkafka::ClientConfig;use tracing::info;@@ -357,6 +358,9 @@ pub struct Config {/// default labels. The lag-based KEDA autoscaler selects on this label.#[envconfig(from = "INGESTION_LANE")]pub ingestion_lane: Option<String>,++ #[envconfig(nested = true)]+ pub continuous_profiling: ContinuousProfilingConfig,}/// Parse `KAFKA_CONSUMER_*` env vars into rdkafka config key-value pairs.diff --git a/rust/ingestion-consumer/src/main.rs b/rust/ingestion-consumer/src/main.rsindex 388ed15b9a40..6f554588fdd1 100644--- a/rust/ingestion-consumer/src/main.rs+++ b/rust/ingestion-consumer/src/main.rs@@ -84,6 +84,16 @@ async fn async_main(config: Config) -> Result<()> {info!("Starting ingestion consumer");+ // Keep the returned agents alive for the duration of the program.+ // Fails gracefully - logs error but doesn't prevent service from starting.+ let _profiling_agents = match config.continuous_profiling.start_agent() {+ Ok(agents) => agents,+ Err(e) => {+ error!("Failed to start continuous profiling agent: {e:#}");+ None+ }+ };+// Lifecycle manager handles signals, health, and shutdown coordinationlet mut manager = Manager::builder("ingestion-consumer").with_global_shutdown_timeout(Duration::from_secs(90))