Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build]
# tokio-console needs this
rustflags = ["--cfg", "tokio_unstable"]
60 changes: 60 additions & 0 deletions Cargo.lock

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

12 changes: 0 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[workspace]
members = [
Expand Down
9 changes: 9 additions & 0 deletions docs/guides/dynamo_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -669,3 +669,12 @@ More fully-featured Backend engines (used by `dynamo-run`):
- [vllm](https://github.com/ai-dynamo/dynamo/blob/main/launch/dynamo-run/src/subprocess/vllm_inc.py)
- [sglang](https://github.com/ai-dynamo/dynamo/blob/main/launch/dynamo-run/src/subprocess/sglang_inc.py)

### Debugging

`dynamo-run` and `dynamo-runtime` support [tokio-console](https://github.com/tokio-rs/console). Build with the feature to enable:
```
cargo build --features cuda,tokio-console -p dynamo-run
```

The listener uses the default tokio console port, and all interfaces (0.0.0.0).

2 changes: 2 additions & 0 deletions launch/dynamo-run/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ metal = ["dynamo-engine-llamacpp/metal", "dynamo-engine-mistralrs/metal"]
vulkan = ["dynamo-engine-llamacpp/vulkan"]
openmp = ["dynamo-engine-llamacpp/openmp"]

tokio-console = ["dynamo-runtime/tokio-console"]

[dependencies]
dynamo-llm = { workspace = true }
dynamo-runtime = { workspace = true }
Expand Down
12 changes: 0 additions & 12 deletions launch/dynamo-run/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use std::env;

Expand Down
24 changes: 3 additions & 21 deletions lib/runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[package]
name = "dynamo-runtime"
Expand All @@ -27,8 +15,8 @@ description = "Dynamo Runtime Library"
[features]
default = []
integration = []
# Tests that require an active ETCD server
testing-etcd = []
testing-etcd = [] # Tests that require an active ETCD server
tokio-console = ["dep:console-subscriber", "tokio/tracing"]

[dependencies]
# Use workspace dependencies where available
Expand Down Expand Up @@ -64,6 +52,7 @@ xxhash-rust = { workspace = true }

arc-swap = { version = "1" }
async-once-cell = { version = "0.5.4" }
console-subscriber = { version = "0.4", optional = true }
educe = { version = "0.6.0" }
figment = { version = "0.10.19", features = ["env", "json", "toml", "test"] }
local-ip-address = { version = "0.6.3" }
Expand All @@ -81,10 +70,3 @@ env_logger = { version = "0.11" }
reqwest = { workspace = true }
rstest = { version = "0.23.0" }
temp-env = { version = "0.3.6" }

# These patches are to address issues in reqwest, which is used in the HTTP server test (but not on servers).
# These are transitive dependencies to use secure versions and mitigate known vulnerabilities.
[patch.crates-io]
tokio = { version = "1.18.4" } # addresses RUSTSEC-2023-0001
h2 = { version = "0.4.4" } # addresses RUSTSEC-2024-0332
rustls = { version = "0.23.18" } # addresses RUSTSEC-2024-0399
119 changes: 70 additions & 49 deletions lib/runtime/src/logging.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! Dynamo Distributed Logging Module.
//!
Expand Down Expand Up @@ -46,6 +34,7 @@ use figment::{
Figment,
};
use serde::{Deserialize, Serialize};
use tracing::level_filters::LevelFilter;
use tracing::{Event, Subscriber};
use tracing_subscriber::fmt::time::FormatTime;
use tracing_subscriber::fmt::time::LocalTime;
Expand All @@ -58,6 +47,8 @@ use tracing_subscriber::registry::LookupSpan;
use tracing_subscriber::EnvFilter;
use tracing_subscriber::{filter::Directive, fmt};

use crate::config::{disable_ansi_logging, jsonl_logging_enabled};

/// ENV used to set the log level
const FILTER_ENV: &str = "DYN_LOG";

Expand Down Expand Up @@ -98,45 +89,75 @@ impl Default for LoggingConfig {

/// Initialize the logger
pub fn init() {
INIT.call_once(|| {
let config = load_config();

// Examples to remove noise
// .add_directive("rustls=warn".parse()?)
// .add_directive("tokio_util::codec=warn".parse()?)
let mut filter_layer = EnvFilter::builder()
.with_default_directive(config.log_level.parse().unwrap())
.with_env_var(FILTER_ENV)
.from_env_lossy();

// apply the log_filters from the config files
for (module, level) in config.log_filters {
match format!("{module}={level}").parse::<Directive>() {
Ok(d) => {
filter_layer = filter_layer.add_directive(d);
}
Err(e) => {
eprintln!("Failed parsing filter '{level}' for module '{module}': {e}");
}
INIT.call_once(setup_logging);
}

#[cfg(feature = "tokio-console")]
fn setup_logging() {
// Start tokio-console server. Returns a tracing-subscriber Layer.
let tokio_console_layer = console_subscriber::ConsoleLayer::builder()
.with_default_env()
.server_addr(([0, 0, 0, 0], console_subscriber::Server::DEFAULT_PORT))
.spawn();
let tokio_console_target = tracing_subscriber::filter::Targets::new()
.with_default(LevelFilter::ERROR)
.with_target("runtime", LevelFilter::TRACE)
.with_target("tokio", LevelFilter::TRACE);
let l = fmt::layer()
.with_ansi(!disable_ansi_logging())
.event_format(fmt::format().compact().with_timer(TimeFormatter::new()))
.with_writer(std::io::stderr)
.with_filter(filter(load_config));
tracing_subscriber::registry()
.with(l)
.with(tokio_console_layer.with_filter(tokio_console_target))
.init();
}

#[cfg(not(feature = "tokio-console"))]
fn setup_logging() {
let f = filters(load_config());
// The generics mean we have to repeat everything. Each builder method returns a
// specialized type.
if jsonl_logging_enabled() {
// JSON logger for NIM

let l = fmt::layer()
.with_ansi(false)
.event_format(CustomJsonFormatter::new())
.with_writer(std::io::stderr)
.with_filter(f);
tracing_subscriber::registry().with(l).init();
} else {
// Normal logging

let l = fmt::layer()
.with_ansi(!disable_ansi_logging())
.event_format(fmt::format().compact().with_timer(TimeFormatter::new()))
.with_writer(std::io::stderr)
.with_filter(f);
tracing_subscriber::registry().with(l).init();
}
}

fn filters(config: LoggingConfig) -> EnvFilter {
let mut filter_layer = EnvFilter::builder()
.with_default_directive(config.log_level.parse().unwrap())
.with_env_var(FILTER_ENV)
.from_env_lossy();

// apply the log_filters from the config files
for (module, level) in config.log_filters {
match format!("{module}={level}").parse::<Directive>() {
Ok(d) => {
filter_layer = filter_layer.add_directive(d);
}
Err(e) => {
eprintln!("Failed parsing filter '{level}' for module '{module}': {e}");
}
}

if crate::config::jsonl_logging_enabled() {
let l = fmt::layer()
.with_ansi(false) // ansi terminal escapes and colors always disabled
.event_format(CustomJsonFormatter::new())
.with_writer(std::io::stderr)
.with_filter(filter_layer);
tracing_subscriber::registry().with(l).init();
} else {
let l = fmt::layer()
.with_ansi(!crate::config::disable_ansi_logging())
.event_format(fmt::format().compact().with_timer(TimeFormatter::new()))
.with_writer(std::io::stderr)
.with_filter(filter_layer);
tracing_subscriber::registry().with(l).init();
};
});
}
filter_layer
}

/// Log a message with file and line info
Expand Down
Loading