mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-17 10:22:56 +00:00
add support for tokio-console & make deps opt-in via feature
This commit is contained in:
@@ -10,6 +10,10 @@ default = []
|
||||
# which adds some runtime cost to run tests on outage conditions
|
||||
testing = ["fail/failpoints"]
|
||||
|
||||
# Enables debugging functionality that's based on the `tracing` crate,
|
||||
# e.g., tokio-console or tracing-chrome.
|
||||
tracing-based-debugging = [ "console-subscriber", "tracing-chrome", "tracing-flame", "tokio/tracing" ]
|
||||
|
||||
[dependencies]
|
||||
arc-swap.workspace = true
|
||||
sentry.workspace = true
|
||||
@@ -20,6 +24,7 @@ bincode.workspace = true
|
||||
bytes.workspace = true
|
||||
camino.workspace = true
|
||||
chrono.workspace = true
|
||||
console-subscriber = {workspace = true, optional = true}
|
||||
diatomic-waker.workspace = true
|
||||
flate2.workspace = true
|
||||
git-version.workspace = true
|
||||
@@ -47,7 +52,9 @@ tokio-tar.workspace = true
|
||||
tokio-util.workspace = true
|
||||
toml_edit = { workspace = true, features = ["serde"] }
|
||||
tracing.workspace = true
|
||||
tracing-chrome = { workspace = true, optional = true }
|
||||
tracing-error.workspace = true
|
||||
tracing-flame = { workspace = true, optional = true }
|
||||
tracing-subscriber = { workspace = true, features = ["json", "registry"] }
|
||||
rand.workspace = true
|
||||
scopeguard.workspace = true
|
||||
@@ -66,8 +73,6 @@ const_format.workspace = true
|
||||
# to use tokio channels as streams, this is faster to compile than async_stream
|
||||
# why is it only here? no other crate should use it, streams are rarely needed.
|
||||
tokio-stream = { version = "0.1.14" }
|
||||
tracing-chrome = "0.7.1"
|
||||
tracing-flame = "0.2.0"
|
||||
|
||||
serde_path_to_error.workspace = true
|
||||
|
||||
@@ -80,6 +85,9 @@ camino-tempfile.workspace = true
|
||||
serde_assert.workspace = true
|
||||
tokio = { workspace = true, features = ["test-util"] }
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)'] }
|
||||
|
||||
[[bench]]
|
||||
name = "benchmarks"
|
||||
harness = false
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use std::{
|
||||
io::BufWriter,
|
||||
num::NonZeroUsize,
|
||||
str::FromStr,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
@@ -189,6 +190,36 @@ pub fn init(
|
||||
},
|
||||
);
|
||||
|
||||
let r = {
|
||||
let varname = "NEON_UTILS_LOGGING_ENABLE_TOKIO_CONSOLE";
|
||||
let console_subscriber_config: Option<NonZeroUsize> = crate::env::var(varname);
|
||||
#[cfg(tokio_unstable)]
|
||||
{
|
||||
r.with(match console_subscriber_config {
|
||||
Some(n) => {
|
||||
use console_subscriber::ConsoleLayer;
|
||||
Some(
|
||||
console_subscriber::Builder::default()
|
||||
.event_buffer_capacity(
|
||||
n.get() * ConsoleLayer::DEFAULT_EVENT_BUFFER_CAPACITY,
|
||||
)
|
||||
.client_buffer_capacity(
|
||||
n.get() * ConsoleLayer::DEFAULT_CLIENT_BUFFER_CAPACITY,
|
||||
)
|
||||
.spawn(),
|
||||
)
|
||||
}
|
||||
None => None,
|
||||
})
|
||||
}
|
||||
#[cfg(not(tokio_unstable))]
|
||||
if console_subscriber_config.is_some() {
|
||||
panic!("recompile with --cfg tokio_unstable to enable {varname}");
|
||||
} else {
|
||||
r
|
||||
}
|
||||
};
|
||||
|
||||
let r = r.with(match tracing_error_layer_enablement {
|
||||
TracingErrorLayerEnablement::EnableWithRustLogFilter => {
|
||||
Some(tracing_error::ErrorLayer::default().with_filter(rust_log_env_filter()))
|
||||
|
||||
Reference in New Issue
Block a user