Skip to content

Commit 69b5adc

Browse files
nshalmanclaude
andcommitted
Add optional tracing support with slog bridge
Add an optional "tracing" feature that enables a bridge between the tracing crate and slog, allowing users to use tracing macros while maintaining slog's structured logging and bunyan format output. Key changes: - Add optional tracing dependencies behind "tracing" feature flag - Implement SlogTracingBridge that converts tracing events to slog records - Preserve structured data types (numbers, booleans) in log output - Use proper detection with tracing::dispatcher::has_been_set() - Initialize bridge automatically when feature is enabled - Add comprehensive tests for bridge functionality The bridge maintains backwards compatibility - existing slog usage continues to work unchanged, and tracing is only available when explicitly enabled via the feature flag. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 615affb commit 69b5adc

File tree

4 files changed

+642
-3
lines changed

4 files changed

+642
-3
lines changed

Cargo.lock

Lines changed: 137 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dropshot/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ slog-async = "2.8.0"
4343
slog-bunyan = "2.5.0"
4444
slog-json = "2.6.1"
4545
slog-term = "2.9.1"
46+
tracing = { version = "0.1.40", optional = true }
47+
tracing-subscriber = { version = "0.3.18", features = ["env-filter"], optional = true }
4648
thiserror = "2.0.12"
4749
tokio-rustls = "0.25.0"
4850
toml = "0.8.23"
@@ -136,6 +138,7 @@ version_check = "0.9.5"
136138
[features]
137139
usdt-probes = ["usdt/asm"]
138140
internal-docs = ["simple-mermaid"]
141+
tracing = ["dep:tracing", "dep:tracing-subscriber"]
139142

140143
[package.metadata.docs.rs]
141144
features = ["internal-docs"]

dropshot/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,8 @@ pub use server::ServerBuilder;
946946
pub use server::ServerContext;
947947
pub use server::ShutdownWaitFuture;
948948
pub use server::{HttpServer, HttpServerStarter};
949+
#[cfg(feature = "tracing")]
950+
pub use tracing::{debug, error, info, trace, warn}; // Re-export tracing macros for convenience
949951
pub use versioning::ClientSpecifiesVersionInHeader;
950952
pub use versioning::DynamicVersionPolicy;
951953
pub use versioning::VersionPolicy;

0 commit comments

Comments
 (0)