Skip to content

Commit

Permalink
refactor(compute): add tracing related args
Browse files Browse the repository at this point in the history
Signed-off-by: MrCroxx <[email protected]>
  • Loading branch information
MrCroxx committed Jun 24, 2024
1 parent 77433bd commit 2ee7576
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 14 deletions.
144 changes: 131 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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" }]
27 changes: 27 additions & 0 deletions src/common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self>,
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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)]
Expand Down
2 changes: 2 additions & 0 deletions src/compute/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
14 changes: 14 additions & 0 deletions src/compute/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 2ee7576

Please sign in to comment.