diff --git a/libs/tool_tracing/Cargo.toml b/libs/tool_tracing/Cargo.toml index 8458d57..715e3ed 100644 --- a/libs/tool_tracing/Cargo.toml +++ b/libs/tool_tracing/Cargo.toml @@ -20,8 +20,6 @@ opentelemetry-otlp = { version = "0.16" } tracing-opentelemetry = "0.24" serde_json = "1.0" tokio = { version = "1.39.2", features = ["rt-multi-thread", "macros"] } -pyroscope = "0.5.7" -pyroscope_pprofrs = "0.2.7" [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = [ diff --git a/libs/tool_tracing/src/init.rs b/libs/tool_tracing/src/init.rs index 583f75b..32e0a39 100644 --- a/libs/tool_tracing/src/init.rs +++ b/libs/tool_tracing/src/init.rs @@ -3,9 +3,6 @@ use super::tracing_kind::{Tracing, TracingKind}; use opentelemetry::KeyValue; use opentelemetry_otlp::WithExportConfig; use opentelemetry_sdk::{runtime, trace, Resource}; -use pyroscope::pyroscope::PyroscopeAgentRunning; -use pyroscope::PyroscopeAgent; -use pyroscope_pprofrs::{pprof_backend, PprofConfig}; use std::{fs::File, sync::Arc, vec}; use time::format_description; use tracing::level_filters::LevelFilter; @@ -17,12 +14,8 @@ use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt; use tracing_subscriber::{fmt, EnvFilter, Layer, Registry}; #[cfg_attr(coverage_nightly, coverage(off))] -pub fn init_tracing( - tracing_config: Vec, - name: String, -) -> Option> { +pub fn init_tracing(tracing_config: Vec, name: String) { let mut layers = vec![]; - let mut super_agent = None; for config in tracing_config { match config.kind { TracingKind::File => { @@ -81,47 +74,17 @@ pub fn init_tracing( let tele_layer = OpenTelemetryLayer::new(telemetry).with_filter(env_filter); layers.push(tele_layer.boxed()); } - TracingKind::Pprof => { - // ERROR ! pprof does not work yet - let sample_rate = match config.additional.get("sample_rate") { - Some(sample_rate) => { - sample_rate.parse().expect("sample_rate should be a number") - } - None => 100, - }; - let backend_impl = pprof_backend(PprofConfig::new().sample_rate(sample_rate)); - let pyro_url = match config.additional.get("pyroscope_url") { - Some(url) => url.to_string(), - None => "http://localhost:4040".to_string(), - }; - let agent = match PyroscopeAgent::builder(pyro_url, name.clone()) - .backend(backend_impl) - .build() - { - Ok(agent) => agent, - Err(e) => panic!("Failed to create pyroscope agent: {}", e), - }; - super_agent = Some(agent.start().unwrap()); - } } } subscriber::set_global_default(Registry::default().with(layers)) .expect("setting default subscriber failed"); - super_agent } #[cfg_attr(coverage_nightly, coverage(off))] -pub fn stop_tracing( - tracing_config: Vec, - _name: String, - super_agent: Option>, -) { +pub fn stop_tracing(tracing_config: Vec, _name: String) { if tracing_config.iter().any(|x| x.kind == TracingKind::Otel) { opentelemetry::global::shutdown_tracer_provider(); } - if tracing_config.iter().any(|x| x.kind == TracingKind::Pprof) { - super_agent.unwrap().shutdown(); - } } #[cfg(test)] @@ -156,11 +119,11 @@ mod tests { tracing_config[2] .additional .insert("endpoint".to_string(), "http://localhost:4317".to_string()); - let agent = init_tracing(tracing_config.clone(), "test".to_string()); + init_tracing(tracing_config.clone(), "test".to_string()); tracing::info!("test part of test_init_tracing"); tracing::error!("test part of test_init_tracing"); tokio::spawn(async { - stop_tracing(tracing_config, "test".to_string(), agent); + stop_tracing(tracing_config, "test".to_string()); }); remove_file("trace.log").unwrap(); } diff --git a/libs/tool_tracing/src/tracing_kind.rs b/libs/tool_tracing/src/tracing_kind.rs index 88fc71f..955e003 100644 --- a/libs/tool_tracing/src/tracing_kind.rs +++ b/libs/tool_tracing/src/tracing_kind.rs @@ -9,7 +9,6 @@ pub enum TracingKind { File, Console, Otel, - Pprof, } #[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]