diff --git a/Cargo.lock b/Cargo.lock index 9fc9ca7f523eb..bb2a5d84fd300 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2392,6 +2392,12 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "cache-padded" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "981520c98f422fcc584dc1a95c334e6953900b9106bc47a9839b81790009eb21" + [[package]] name = "cache_control" version = "0.2.0" @@ -3385,6 +3391,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "ctor" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" +dependencies = [ + "quote", + "syn 1.0.109", +] + [[package]] name = "ctr" version = "0.9.2" @@ -5342,8 +5358,7 @@ dependencies = [ [[package]] name = "foyer" version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0720e9cc504174e952382345ea25fe887fbd4c1761dccdd4c5276c6d1a93dbc5" +source = "git+https://github.com/MrCroxx/foyer?rev=fe904bc#fe904bc120926c91d45c142c63288317ecb2bd3e" dependencies = [ "ahash 0.8.11", "anyhow", @@ -5351,24 +5366,27 @@ dependencies = [ "foyer-memory", "foyer-storage", "madsim-tokio", + "minitrace", "tracing", ] [[package]] name = "foyer-common" version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a823da3228992cc6392ddac757e0ed44fa4923588b03fcbbba4bad1ebfea7b2" +source = "git+https://github.com/MrCroxx/foyer?rev=fe904bc#fe904bc120926c91d45c142c63288317ecb2bd3e" dependencies = [ "bytes", "cfg-if", "crossbeam", + "futures", "hashbrown 0.14.3", "itertools 0.13.0", "madsim-tokio", "metrics", + "minitrace", "nix 0.29.0", "parking_lot 0.12.1", + "pin-project", "rustversion", "serde", ] @@ -5376,8 +5394,7 @@ dependencies = [ [[package]] name = "foyer-intrusive" version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5168b34c3e6369a4c6055f08c6b37e416910652bfdd9a84de55a602f2aa3dcea" +source = "git+https://github.com/MrCroxx/foyer?rev=fe904bc#fe904bc120926c91d45c142c63288317ecb2bd3e" dependencies = [ "foyer-common", "itertools 0.13.0", @@ -5386,8 +5403,7 @@ dependencies = [ [[package]] name = "foyer-memory" version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56055774fa6ed25d0affe30c04e6a3f18fc00713a42ef6a3dbd96e72fe31a3eb" +source = "git+https://github.com/MrCroxx/foyer?rev=fe904bc#fe904bc120926c91d45c142c63288317ecb2bd3e" dependencies = [ "ahash 0.8.11", "bitflags 2.5.0", @@ -5399,6 +5415,7 @@ dependencies = [ "itertools 0.13.0", "libc", "madsim-tokio", + "minitrace", "parking_lot 0.12.1", "serde", "tracing", @@ -5407,8 +5424,7 @@ dependencies = [ [[package]] name = "foyer-storage" version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74811aec3df193b9c304d031e9f4879c4aab86cb78ff6e4cadf1188d014e7069" +source = "git+https://github.com/MrCroxx/foyer?rev=fe904bc#fe904bc120926c91d45c142c63288317ecb2bd3e" dependencies = [ "ahash 0.8.11", "allocator-api2", @@ -5427,6 +5443,7 @@ dependencies = [ "libc", "lz4", "madsim-tokio", + "minitrace", "parking_lot 0.12.1", "pin-project", "rand", @@ -5868,7 +5885,7 @@ dependencies = [ "http 0.2.9", "thiserror", "tokio", - "tonic 0.10.2", + "tonic 0.11.0", "tower", "tracing", "trust-dns-resolver 0.23.2", @@ -7643,6 +7660,44 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[package]] +name = "minitrace" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "197d538cd69839d49a593c8c72df44291b0ea3296ecc0c85529002c53c8fbc6f" +dependencies = [ + "minitrace-macro", + "minstant", + "once_cell", + "parking_lot 0.12.1", + "pin-project", + "rand", + "rtrb", +] + +[[package]] +name = "minitrace-jaeger" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e63612364589c56423b9d3d08083adfadc44570158b49bc76a10562214785d2" +dependencies = [ + "log", + "minitrace", + "thrift_codec", +] + +[[package]] +name = "minitrace-macro" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14efd4b574325fcb981bce1ac700b9ccf071ec2eb94f7a6a6b583a84f228ba47" +dependencies = [ + "proc-macro-error 1.0.4", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "miniz_oxide" version = "0.7.2" @@ -7652,6 +7707,16 @@ dependencies = [ "adler", ] +[[package]] +name = "minstant" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fb9b5c752f145ac5046bccc3c4f62892e3c950c1d1eab80c5949cd68a2078db" +dependencies = [ + "ctor", + "web-time 1.1.0", +] + [[package]] name = "mio" version = "0.8.11" @@ -9795,7 +9860,7 @@ dependencies = [ "indoc", "libc", "memoffset", - "parking_lot 0.11.2", + "parking_lot 0.12.1", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -10927,6 +10992,8 @@ dependencies = [ "madsim-tokio", "madsim-tonic", "maplit", + "minitrace", + "minitrace-jaeger", "pprof", "prometheus", "prost 0.12.1", @@ -12266,6 +12333,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rtrb" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99e704dd104faf2326a320140f70f0b736d607c1caa1b1748a6c568a79819109" +dependencies = [ + "cache-padded", +] + [[package]] name = "rumqttc" version = "0.24.0" @@ -14785,6 +14861,16 @@ dependencies = [ "ordered-float 2.10.0", ] +[[package]] +name = "thrift_codec" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d957f535b242b91aa9f47bde08080f9a6fef276477e55b0079979d002759d5" +dependencies = [ + "byteorder", + "trackable", +] + [[package]] name = "tiberius" version = "0.12.2" @@ -15248,7 +15334,10 @@ dependencies = [ "percent-encoding", "pin-project", "prost 0.12.1", + "rustls-pemfile 2.1.1", + "rustls-pki-types", "tokio", + "tokio-rustls 0.25.0", "tokio-stream", "tower", "tower-layer", @@ -15410,7 +15499,7 @@ dependencies = [ "tracing-core", "tracing-log 0.2.0", "tracing-subscriber", - "web-time", + "web-time 0.2.3", ] [[package]] @@ -15469,6 +15558,25 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "trackable" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15bd114abb99ef8cee977e517c8f37aee63f184f2d08e3e6ceca092373369ae" +dependencies = [ + "trackable_derive", +] + +[[package]] +name = "trackable_derive" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebeb235c5847e2f82cfe0f07eb971d1e5f6804b18dac2ae16349cc604380f82f" +dependencies = [ + "quote", + "syn 1.0.109", +] + [[package]] name = "trim-in-place" version = "0.1.7" @@ -16532,6 +16640,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki" version = "0.22.4" diff --git a/Cargo.toml b/Cargo.toml index 249a0f2258863..16d11586fc531 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,7 +76,7 @@ license = "Apache-2.0" repository = "https://github.com/risingwavelabs/risingwave" [workspace.dependencies] -foyer = { version = "0.9.4", features = ["nightly"] } +foyer = { version = "0.9.4", features = ["nightly", "mtrace"] } apache-avro = { git = "https://github.com/risingwavelabs/avro", rev = "25113ba88234a9ae23296e981d8302c290fdaa4b", features = [ "snappy", "zstandard", @@ -340,6 +340,8 @@ deno_web = { git = "https://github.com/bakjos/deno", rev = "787a232" } deno_websocket = { git = "https://github.com/bakjos/deno", rev = "787a232" } # patch to remove preserve_order from serde_json bson = { git = "https://github.com/risingwavelabs/bson-rust", rev = "e5175ec" } +# temporarily patch until foyer release v0.10 +foyer = { git = "https://github.com/MrCroxx/foyer", rev = "fe904bc" } [workspace.metadata.dylint] libraries = [{ path = "./lints" }] diff --git a/src/common/src/config.rs b/src/common/src/config.rs index a554e220ec632..e45b0c925bae1 100644 --- a/src/common/src/config.rs +++ b/src/common/src/config.rs @@ -487,6 +487,9 @@ pub struct ServerConfig { #[serde(default = "default::server::grpc_max_reset_stream_size")] pub grpc_max_reset_stream: u32, + #[serde(default)] + pub tracing: TracingConfig, + #[serde(default, flatten)] #[config_doc(omitted)] pub unrecognized: Unrecognized, @@ -1246,6 +1249,20 @@ impl SystemConfig { } } +#[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde)] +pub struct TracingConfig { + /// Url of jaeger for tracing data collection. + /// + /// Tracing will be disabled if no valid jaeger url is set. + /// + /// Example: "127.0.0.1:6831". + #[serde(default = "default::tracing_config::jaeger")] + pub jaeger: String, + /// Interval for minitrace reporter reports in ms. + #[serde(default = "default::tracing_config::report_interval_ms")] + pub report_interval_ms: u64, +} + pub mod default { pub mod meta { use crate::config::{DefaultParallelism, MetaBackend}; @@ -2075,6 +2092,16 @@ pub mod default { } } } + + pub mod tracing_config { + pub fn jaeger() -> String { + "".to_string() + } + + pub fn report_interval_ms() -> u64 { + 10 + } + } } #[derive(Debug, Clone)] diff --git a/src/compute/Cargo.toml b/src/compute/Cargo.toml index 817578db32631..7ca42fd3e3517 100644 --- a/src/compute/Cargo.toml +++ b/src/compute/Cargo.toml @@ -26,6 +26,8 @@ futures-async-stream = { workspace = true } hyper = "0.14" # required by tonic itertools = { workspace = true } maplit = "1.0.2" +minitrace = "0.6.7" +minitrace-jaeger = "0.6.7" pprof = { version = "0.13", features = ["flamegraph"] } prometheus = { version = "0.13" } prost = { workspace = true } diff --git a/src/compute/src/server.rs b/src/compute/src/server.rs index a28631a29bea6..8c5d281051ba9 100644 --- a/src/compute/src/server.rs +++ b/src/compute/src/server.rs @@ -395,6 +395,20 @@ pub async fn compute_node_serve( tracing::info!("Telemetry didn't start due to config"); } + let service = format!("compute-{worker_id}"); + if let Ok(agent) = config.server.tracing.jaeger.parse() { + let reporter = minitrace_jaeger::JaegerReporter::new(agent, &service).unwrap(); + minitrace::set_reporter( + reporter, + minitrace::collector::Config::default().report_interval(Duration::from_millis( + config.server.tracing.report_interval_ms, + )), + ); + tracing::info!("Jaeger exporter for {service} is set at {agent:?}."); + } else { + tracing::info!("Jaeger exporter for {service} is disabled.") + } + // Clean up the spill directory. #[cfg(not(madsim))] SpillOp::clean_spill_directory().await.unwrap(); diff --git a/src/config/docs.md b/src/config/docs.md index a52ce9202a3b3..c473e68a8bfdd 100644 --- a/src/config/docs.md +++ b/src/config/docs.md @@ -95,6 +95,7 @@ This page is automatically generated by `./risedev generate-example-config` | heartbeat_interval_ms | The interval for periodic heartbeat from worker to the meta service. | 1000 | | metrics_level | Used for control the metrics level, similar to log level. | "Info" | | telemetry_enabled | | true | +| tracing | | | ## storage diff --git a/src/config/example.toml b/src/config/example.toml index a708fed3b84bf..27ffd9653be11 100644 --- a/src/config/example.toml +++ b/src/config/example.toml @@ -13,6 +13,10 @@ enable_auto = true threshold_auto = 0.8999999761581421 dir = "./" +[server.tracing] +jaeger = "" +report_interval_ms = 10 + [meta] min_sst_retention_time_sec = 86400 full_gc_interval_sec = 86400