Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support UDS listen address for tokio-console #16537

Merged
merged 2 commits into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

31 changes: 22 additions & 9 deletions doc/developer/guide-tokio-console.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
# Developer guide: `tokio-console`

This guide details how to run `tokio-console` with `materialized`
This guide details how to run `tokio-console` with Materialize.

## Overview

First, install `tokio-console`:
First, install `tokio-console`. We require support for Unix domain sockets, [which is still pending
upstream][uds-pr], so we need to install from a fork for now.

```
cargo install tokio-console
```text
cargo install tokio-console --git https://github.com/MaterializeInc/console.git
```

Then run `environmentd`:

```
```text
./bin/environmentd --tokio-console
```

(note that this may slow down `environmentd` a lot, as it increases the amount of tracing by a lot,
and may inadvertently turn on debug logging for `rdkafka`)
(Note that this may slow down `environmentd` a lot, as it increases the amount of tracing by a lot,
and may inadvertently turn on debug logging for `rdkafka`.)

Then, in a different tmux pane/terminal, run:
In the output of the above command, take note of the `tokio-console` listen addresses for the
different processes, e.g.:

```text
environmentd: [...] INFO mz_ore::tracing: starting tokio console on http://127.0.0.1:6669
compute-cluster-u1-replica-1: [...] INFO mz_ore::tracing: starting tokio console on /var/folders/30/[...]3ee9
compute-cluster-s1-replica-2: [...] INFO mz_ore::tracing: starting tokio console on /var/folders/30/[...]f5b6
compute-cluster-s2-replica-3: [...] INFO mz_ore::tracing: starting tokio console on /var/folders/30/[...]7af2
```
tokio-console

Then, in a different tmux pane/terminal, run the `tokio-console` command with the listen address of
your process of interest:

```text
tokio-console <listen-address>
```

This [README] has some docs on how to navigate the ui.

[uds-pr]: https://github.com/tokio-rs/console/pull/388
[README]: https://github.com/tokio-rs/console/tree/main/tokio-console

### Notes on compilation times:
Expand Down
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/MaterializeInc/console.git", 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) => format!("file://localhost{addr}"),
};
tracing::info!("starting tokio console on {endpoint}");
}

Ok((
Expand Down