add tokio console subscriber

This commit is contained in:
Conrad Ludgate
2024-01-16 13:51:34 +00:00
parent 4b0204ede5
commit a1cc1a6373
5 changed files with 120 additions and 14 deletions

120
Cargo.lock generated
View File

@@ -1226,6 +1226,43 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "console-api"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd326812b3fd01da5bb1af7d340d0d555fd3d4b641e7f1dfcf5962a902952787"
dependencies = [
"futures-core",
"prost 0.12.3",
"prost-types 0.12.3",
"tonic 0.10.2",
"tracing-core",
]
[[package]]
name = "console-subscriber"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7481d4c57092cd1c19dd541b92bdce883de840df30aa5d03fd48a3935c01842e"
dependencies = [
"console-api",
"crossbeam-channel",
"crossbeam-utils",
"futures-task",
"hdrhistogram",
"humantime",
"prost-types 0.12.3",
"serde",
"serde_json",
"thread_local",
"tokio",
"tokio-stream",
"tonic 0.10.2",
"tracing",
"tracing-core",
"tracing-subscriber",
]
[[package]]
name = "const-oid"
version = "0.9.5"
@@ -3094,7 +3131,7 @@ dependencies = [
"opentelemetry",
"opentelemetry-http",
"opentelemetry-proto",
"prost",
"prost 0.11.9",
"reqwest",
"thiserror",
]
@@ -3108,7 +3145,7 @@ dependencies = [
"futures",
"futures-util",
"opentelemetry",
"prost",
"prost 0.11.9",
"tonic 0.8.3",
]
@@ -3823,7 +3860,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd"
dependencies = [
"bytes",
"prost-derive",
"prost-derive 0.11.9",
]
[[package]]
name = "prost"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a"
dependencies = [
"bytes",
"prost-derive 0.12.3",
]
[[package]]
@@ -3840,8 +3887,8 @@ dependencies = [
"multimap",
"petgraph",
"prettyplease 0.1.25",
"prost",
"prost-types",
"prost 0.11.9",
"prost-types 0.11.9",
"regex",
"syn 1.0.109",
"tempfile",
@@ -3861,13 +3908,35 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "prost-derive"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e"
dependencies = [
"anyhow",
"itertools",
"proc-macro2",
"quote",
"syn 2.0.32",
]
[[package]]
name = "prost-types"
version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13"
dependencies = [
"prost",
"prost 0.11.9",
]
[[package]]
name = "prost-types"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e"
dependencies = [
"prost 0.12.3",
]
[[package]]
@@ -3883,6 +3952,7 @@ dependencies = [
"camino-tempfile",
"chrono",
"clap",
"console-subscriber",
"consumption_metrics",
"dashmap",
"futures",
@@ -5148,7 +5218,7 @@ dependencies = [
"metrics",
"once_cell",
"parking_lot 0.12.1",
"prost",
"prost 0.11.9",
"tokio",
"tokio-stream",
"tonic 0.9.2",
@@ -5467,6 +5537,7 @@ dependencies = [
"signal-hook-registry",
"socket2 0.5.5",
"tokio-macros",
"tracing",
"windows-sys 0.48.0",
]
@@ -5657,8 +5728,8 @@ dependencies = [
"hyper-timeout",
"percent-encoding",
"pin-project",
"prost",
"prost-derive",
"prost 0.11.9",
"prost-derive 0.11.9",
"tokio",
"tokio-stream",
"tokio-util",
@@ -5689,7 +5760,7 @@ dependencies = [
"hyper-timeout",
"percent-encoding",
"pin-project",
"prost",
"prost 0.11.9",
"rustls-native-certs",
"rustls-pemfile",
"tokio",
@@ -5701,6 +5772,33 @@ dependencies = [
"tracing",
]
[[package]]
name = "tonic"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e"
dependencies = [
"async-stream",
"async-trait",
"axum",
"base64 0.21.1",
"bytes",
"h2",
"http",
"http-body",
"hyper",
"hyper-timeout",
"percent-encoding",
"pin-project",
"prost 0.12.3",
"tokio",
"tokio-stream",
"tower",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
name = "tonic-build"
version = "0.9.2"
@@ -6606,7 +6704,7 @@ dependencies = [
"num-traits",
"once_cell",
"parquet",
"prost",
"prost 0.11.9",
"rand 0.8.5",
"regex",
"regex-automata 0.4.3",

View File

@@ -64,6 +64,7 @@ cfg-if = "1.0.0"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
clap = { version = "4.0", features = ["derive"] }
close_fds = "0.3.2"
console-subscriber = "0.2.0"
comfy-table = "6.1"
const_format = "0.2"
crc32c = "0.6"

View File

@@ -35,6 +35,7 @@ ARG BUILD_TAG
ARG RUSTC_WRAPPER=cachepot
ENV AWS_REGION=eu-central-1
ENV CACHEPOT_S3_KEY_PREFIX=cachepot
ENV RUSTFLAGS="--cfg tokio_unstable"
ARG CACHEPOT_BUCKET=neon-github-dev
#ARG AWS_ACCESS_KEY_ID
#ARG AWS_SECRET_ACCESS_KEY

View File

@@ -5,8 +5,9 @@ edition.workspace = true
license.workspace = true
[features]
default = ["testing"]
default = ["tokio-console"]
testing = []
tokio-console = ["tokio/tracing", "dep:console-subscriber"]
[dependencies]
anyhow.workspace = true
@@ -17,6 +18,7 @@ bytes = { workspace = true, features = ["serde"] }
camino.workspace = true
chrono.workspace = true
clap.workspace = true
console-subscriber = { workspace = true, optional = true }
consumption_metrics.workspace = true
dashmap.workspace = true
futures.workspace = true

View File

@@ -26,8 +26,12 @@ pub async fn init() -> anyhow::Result<LoggingGuard> {
.await
.map(OpenTelemetryLayer::new);
tracing_subscriber::registry()
.with(env_filter)
let reg = tracing_subscriber::registry();
#[cfg(feature = "tokio-console")]
let reg = reg.with(console_subscriber::spawn());
reg.with(env_filter)
.with(otlp_layer)
.with(fmt_layer)
.try_init()?;