Skip to content

Commit af5903d

Browse files
author
Devdutt Shenoi
authored
feat: env_logger ~> tracing_subscriber (#997)
This PR adds advanced Tracing: - Supports spans, which represent scopes of work and can include nested spans for hierarchical logging. - Collects rich metadata about events and spans (e.g., source location, fields, etc.). - Allows dynamic configuration and advanced filtering (e.g., by span, field, or metadata). Subscribers: - Provides customizable subscribers for processing trace data (e.g., fmt, json, or custom handlers). - Offers flexibility in output formats, including JSON or custom formats. - Integration: Works with other tools like tracing-opentelemetry for distributed tracing.
1 parent bfca663 commit af5903d

File tree

3 files changed

+107
-31
lines changed

3 files changed

+107
-31
lines changed

Cargo.lock

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

server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ clap = { version = "4.1", default-features = false, features = [
5555
clokwerk = "0.4"
5656
crossterm = "0.28.1"
5757
derive_more = "0.99.18"
58-
env_logger = "0.11.3"
5958
fs_extra = "1.3"
6059
futures = "0.3"
6160
futures-util = "0.3.28"
@@ -90,6 +89,7 @@ tokio = { version = "1.28", default-features = false, features = [
9089
"fs",
9190
] }
9291
tokio-stream = { version = "0.1", features = ["fs"] }
92+
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
9393
ulid = { version = "1.0", features = ["serde"] }
9494
uptime_lib = "0.3.0"
9595
xxhash-rust = { version = "0.8", features = ["xxh3"] }

server/src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ use std::sync::Arc;
4848

4949
use handlers::http::modal::ParseableServer;
5050
use option::{Mode, CONFIG};
51+
use tracing_subscriber::EnvFilter;
5152

5253
use crate::handlers::http::modal::{
5354
ingest_server::IngestServer, query_server::QueryServer, server::Server,
@@ -56,7 +57,10 @@ pub const STORAGE_UPLOAD_INTERVAL: u32 = 60;
5657

5758
#[actix_web::main]
5859
async fn main() -> anyhow::Result<()> {
59-
env_logger::init();
60+
tracing_subscriber::fmt()
61+
.with_env_filter(EnvFilter::from_default_env())
62+
.compact()
63+
.init();
6064

6165
// these are empty ptrs so mem footprint should be minimal
6266
let server: Arc<dyn ParseableServer> = match CONFIG.parseable.mode {

0 commit comments

Comments
 (0)