[Rust Frontend] Extract shared tracing setup logic into `vllm-tracing` (#50129)
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Bugen Zhao committed
Jul 29, 2026 at 03:31 UTC
d552a68645b60fe194ed488e9c3df211e4d2fa6f
8 files changed
+35
-21
rust/Cargo.lock
+11
-3
@@ -5503,9 +5503,9 @@ dependencies = [
5503
"tokio",
5504
"tokio-stream",
5505
"tracing",
5506
- "tracing-subscriber",
5506
"url",
5507
"uuid",
5508
+ "vllm-tracing",
5509
]
5510
5511
[[package]]
@@ -5570,17 +5570,16 @@ dependencies = [
5570
"serde_json",
5571
"serde_with",
5572
"thiserror-ext",
5573
- "time",
5573
"tokio",
5574
"tokio-util",
5575
"tracing",
5577
- "tracing-subscriber",
5576
"uuid",
5577
"vllm-bench",
5578
"vllm-chat",
5579
"vllm-engine-core-client",
5580
"vllm-managed-engine",
5581
"vllm-server",
5582
+ "vllm-tracing",
5583
]
5584
5585
[[package]]
@@ -5827,6 +5826,15 @@ dependencies = [
5826
"vllm-parser",
5827
]
5828
5829
+[[package]]
5830
+name = "vllm-tracing"
5831
+version = "0.1.0"
5832
+dependencies = [
5833
+ "time",
5834
+ "tracing",
5835
+ "tracing-subscriber",
5836
+]
5837
+
5838
[[package]]
5839
name = "walkdir"
5840
version = "2.5.0"
rust/Cargo.toml
+2
@@ -13,6 +13,7 @@ members = [
13
"src/server",
14
"src/text",
15
"src/tokenizer",
16
+ "src/tracing",
17
]
18
resolver = "3"
19
@@ -143,6 +144,7 @@ vllm-parser = { path = "src/parser" }
144
vllm-server = { path = "src/server" }
145
vllm-text = { path = "src/text" }
146
vllm-tokenizer = { path = "src/tokenizer" }
147
+vllm-tracing = { path = "src/tracing" }
148
winnow = { version = "1.0.2", features = ["simd"] }
149
xgrammar-structural-tag = "0.2.0"
150
zeromq = { version = "0.6.0", default-features = false, features = [
rust/src/bench/Cargo.toml
+1
-1
@@ -32,9 +32,9 @@ tokenizers.workspace = true
32
tokio.workspace = true
33
tokio-stream.workspace = true
34
tracing.workspace = true
35
-tracing-subscriber.workspace = true
35
url.workspace = true
36
uuid.workspace = true
37
+vllm-tracing.workspace = true
38
39
[lints]
40
workspace = true
rust/src/bench/src/main.rs
+1
-11
@@ -19,18 +19,8 @@ struct Cli {
19
args: vllm_bench::BenchServeArgs,
20
}
21
22
-// TODO: unify the tracing subscriber used by different binaries.
23
-fn init_tracing() {
24
- let filter = tracing_subscriber::EnvFilter::try_from_default_env()
25
- .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"));
26
- let _ = tracing_subscriber::fmt()
27
- .with_env_filter(filter)
28
- .with_writer(std::io::stderr)
29
- .try_init();
30
-}
31
-
22
fn main() -> anyhow::Result<()> {
33
- init_tracing();
23
+ vllm_tracing::init_tracing("Bench");
24
25
let cli = Cli::parse();
26
vllm_bench::prepare_process();
rust/src/cmd/Cargo.toml
+1
-2
@@ -23,17 +23,16 @@ serde.workspace = true
23
serde_json.workspace = true
24
serde_with.workspace = true
25
thiserror-ext.workspace = true
26
-time.workspace = true
26
tokio = { workspace = true, features = ["signal"] }
27
tokio-util.workspace = true
28
tracing.workspace = true
30
-tracing-subscriber.workspace = true
29
uuid.workspace = true
30
vllm-bench.workspace = true
31
vllm-chat.workspace = true
32
vllm-engine-core-client.workspace = true
33
vllm-managed-engine.workspace = true
34
vllm-server.workspace = true
35
+vllm-tracing.workspace = true
36
37
[dev-dependencies]
38
expect-test.workspace = true
rust/src/cmd/src/main.rs
+1
-2
@@ -2,7 +2,6 @@
2
// SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4
mod cli;
5
-mod logging;
5
6
use std::env;
7
use std::ffi::OsStr;
@@ -89,7 +88,7 @@ fn main() -> Result<()> {
88
"serve" | "frontend" => "RustFrontend",
89
_ => "Rust",
90
};
92
- logging::init_tracing(process_label);
91
+ vllm_tracing::init_tracing(process_label);
92
93
let cli = Cli::parse();
94
rust/src/tracing/Cargo.toml
new
+14
@@ -0,0 +1,14 @@
1
+[package]
2
+name = "vllm-tracing"
3
+version.workspace = true
4
+edition.workspace = true
5
+description = "Shared tracing subscriber and log formatting for vLLM Rust binaries"
6
+license.workspace = true
7
+
8
+[dependencies]
9
+time.workspace = true
10
+tracing.workspace = true
11
+tracing-subscriber.workspace = true
12
+
13
+[lints]
14
+workspace = true
rust/src/tracing/src/lib.rs
renamed
+4
-2
@@ -1,6 +1,8 @@
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4
+//! Shared tracing subscriber and log formatting for vLLM Rust binaries.
5
+
6
use std::{env, fmt, process};
7
8
use time::UtcOffset;
@@ -26,8 +28,8 @@ const RESET: &str = "\x1b[0m";
28
const VLLM_TIME_FORMAT: &[time::format_description::FormatItem<'static>] =
29
format_description!("[month]-[day] [hour]:[minute]:[second]");
30
29
-/// Install the process-wide vLLM-style tracing subscriber for the CLI binary.
30
-pub(crate) fn init_tracing(process_label: &str) {
31
+/// Install the process-wide vLLM-style tracing subscriber.
32
+pub fn init_tracing(process_label: &str) {
33
let filter = build_targets_filter(
34
env::var("VLLM_LOGGING_LEVEL").ok().as_deref(),
35
env::var("RUST_LOG").ok().as_deref(),