forked from vectordotdev/vector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrace.rs
More file actions
41 lines (35 loc) · 1.08 KB
/
Copy pathtrace.rs
File metadata and controls
41 lines (35 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use metrics_tracing_context::MetricsLayer;
use tracing::{
dispatcher::{set_global_default, Dispatch},
span::Span,
};
use tracing_limit::Limit;
use tracing_log::LogTracer;
use tracing_subscriber::{layer::SubscriberExt, FmtSubscriber};
pub use tracing_futures::Instrument;
pub use tracing_tower::{InstrumentableService, InstrumentedService};
pub fn init(color: bool, json: bool, levels: &str) {
let dispatch = if json {
let subscriber = FmtSubscriber::builder()
.with_env_filter(levels)
.json()
.flatten_event(true)
.finish()
.with(Limit::default())
.with(MetricsLayer::new());
Dispatch::new(subscriber)
} else {
let subscriber = FmtSubscriber::builder()
.with_ansi(color)
.with_env_filter(levels)
.finish()
.with(Limit::default())
.with(MetricsLayer::new());
Dispatch::new(subscriber)
};
let _ = LogTracer::init();
let _ = set_global_default(dispatch);
}
pub fn current_span() -> Span {
Span::current()
}