Skip to content

Commit

Permalink
Support UDS listen address for tokio-console
Browse files Browse the repository at this point in the history
This commit fixes local tokio-console support, which was broken in
ac1028d because tokio-console does not support Unix domain sockets
(yet).

The fix involves adding that support by switching to Nikhil's fork of
concole-subscriber and using the `mz_ore::netio::SocketAddr` type for
the tokio-console listen address.
  • Loading branch information
teskje authored and benesch committed Dec 11, 2022
1 parent 165f706 commit 81116d3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
6 changes: 2 additions & 4 deletions Cargo.lock

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

12 changes: 6 additions & 6 deletions src/orchestrator-tracing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
use std::collections::HashMap;
use std::ffi::OsString;
use std::fmt;
#[cfg(feature = "tokio-console")]
use std::net::SocketAddr;
use std::str::FromStr;
use std::sync::Arc;
#[cfg(feature = "tokio-console")]
Expand All @@ -35,6 +33,8 @@ use mz_orchestrator::{
};
use mz_ore::cli::{DefaultTrue, KeyValueArg};
#[cfg(feature = "tokio-console")]
use mz_ore::netio::SocketAddr;
#[cfg(feature = "tokio-console")]
use mz_ore::tracing::TokioConsoleConfig;
use mz_ore::tracing::{
OpenTelemetryConfig, SentryConfig, StderrLogConfig, StderrLogFormat, TracingConfig,
Expand Down Expand Up @@ -227,13 +227,13 @@ impl From<&TracingCliArgs> for TracingConfig {
}
}),
#[cfg(feature = "tokio-console")]
tokio_console: args
.tokio_console_listen_addr
.map(|listen_addr| TokioConsoleConfig {
tokio_console: args.tokio_console_listen_addr.clone().map(|listen_addr| {
TokioConsoleConfig {
listen_addr,
publish_interval: args.tokio_console_publish_interval,
retention: args.tokio_console_retention,
}),
}
}),
sentry: args.sentry_dsn.clone().map(|dsn| SentryConfig {
dsn,
tags: args
Expand Down
2 changes: 1 addition & 1 deletion src/ore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ hyper = { version = "0.14.23", features = ["http1", "server"], optional = true }
hyper-tls = { version = "0.5.0", optional = true }
opentelemetry = { git = "https://github.com/MaterializeInc/opentelemetry-rust.git", features = ["rt-tokio", "trace"], optional = true }
opentelemetry-otlp = { git = "https://github.com/MaterializeInc/opentelemetry-rust.git", optional = true }
console-subscriber = { version = "0.1.8", optional = true }
console-subscriber = { git = "https://github.com/benesch/tokio-console.git", branch = "uds", optional = true }
sentry-tracing = { version = "0.29.0", optional = true }

[dev-dependencies]
Expand Down
29 changes: 18 additions & 11 deletions src/ore/src/tracing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
use std::borrow::Cow;
use std::collections::HashMap;
use std::io;
#[cfg(feature = "tokio-console")]
use std::net::SocketAddr;
use std::sync::Arc;
use std::time::Duration;

Expand All @@ -50,6 +48,9 @@ use tracing_subscriber::registry::LookupSpan;
use tracing_subscriber::util::SubscriberInitExt;
use tracing_subscriber::{reload, Registry};

#[cfg(feature = "tokio-console")]
use crate::netio::SocketAddr;

/// Application tracing configuration.
///
/// See the [`configure`] function for details.
Expand Down Expand Up @@ -330,12 +331,17 @@ where

#[cfg(feature = "tokio-console")]
let tokio_console_layer = if let Some(console_config) = config.tokio_console.clone() {
let layer = ConsoleLayer::builder()
.server_addr(console_config.listen_addr)
let builder = ConsoleLayer::builder()
.publish_interval(console_config.publish_interval)
.retention(console_config.retention)
.spawn();
Some(layer)
.retention(console_config.retention);
let builder = match console_config.listen_addr {
SocketAddr::Inet(addr) => builder.server_addr(addr),
SocketAddr::Unix(addr) => {
let path = addr.as_pathname().unwrap().as_ref();
builder.server_addr(path)
}
};
Some(builder.spawn())
} else {
None
};
Expand Down Expand Up @@ -373,10 +379,11 @@ where

#[cfg(feature = "tokio-console")]
if let Some(console_config) = config.tokio_console {
tracing::info!(
"starting tokio console on http://{}",
console_config.listen_addr
);
let endpoint = match console_config.listen_addr {
SocketAddr::Inet(addr) => format!("http://{addr}"),
SocketAddr::Unix(addr) => addr.to_string(),
};
tracing::info!("starting tokio console on {endpoint}");
}

Ok((
Expand Down

0 comments on commit 81116d3

Please sign in to comment.