File tree Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,11 @@ Options:
290290
291291 [env: JSON_OUTPUT=]
292292
293+ --disable-spans
294+ Disables the span logging trace
295+
296+ [env: DISABLE_SPANS=]
297+
293298 --otlp-endpoint <OTLP_ENDPOINT>
294299 The grpc endpoint for opentelemetry. Telemetry is sent to this endpoint as OTLP over gRPC. e.g. `http://localhost:4317`
295300
Original file line number Diff line number Diff line change @@ -182,6 +182,11 @@ Options:
182182
183183 [env: JSON_OUTPUT=]
184184
185+ --disable-spans
186+ Disables the span logging trace
187+
188+ [env: DISABLE_SPANS=]
189+
185190 --otlp-endpoint <OTLP_ENDPOINT>
186191 The grpc endpoint for opentelemetry. Telemetry is sent to this endpoint as OTLP over gRPC. e.g. `http://localhost:4317`
187192
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ pub fn init_logging(
1414 otlp_endpoint : Option < & String > ,
1515 otlp_service_name : String ,
1616 json_output : bool ,
17+ disable_spans : bool ,
1718) -> bool {
1819 let mut layers = Vec :: new ( ) ;
1920
@@ -22,10 +23,15 @@ pub fn init_logging(
2223 . with_file ( true )
2324 . with_line_number ( true ) ;
2425
25- let fmt_layer = match json_output {
26- true => fmt_layer. json ( ) . flatten_event ( true ) . boxed ( ) ,
27- false => fmt_layer. boxed ( ) ,
28- } ;
26+ let fmt_layer = match json_output {
27+ true => fmt_layer
28+ . json ( )
29+ . flatten_event ( true )
30+ . with_current_span ( !disable_spans)
31+ . with_span_list ( !disable_spans)
32+ . boxed ( ) ,
33+ false => fmt_layer. boxed ( ) ,
34+ } ;
2935 layers. push ( fmt_layer) ;
3036
3137 // OpenTelemetry tracing layer
Original file line number Diff line number Diff line change @@ -150,6 +150,10 @@ struct Args {
150150 #[ clap( long, env) ]
151151 json_output : bool ,
152152
153+ // Whether or not to include the log trace through spans
154+ #[ clap( long, env) ]
155+ disable_spans : bool ,
156+
153157 /// The grpc endpoint for opentelemetry. Telemetry is sent to this endpoint as OTLP over gRPC.
154158 /// e.g. `http://localhost:4317`
155159 #[ clap( long, env) ]
@@ -175,6 +179,7 @@ async fn main() -> Result<()> {
175179 args. otlp_endpoint . as_ref ( ) ,
176180 args. otlp_service_name . clone ( ) ,
177181 args. json_output ,
182+ args. disable_spans ,
178183 ) ;
179184
180185 tracing:: info!( "{args:?}" ) ;
You can’t perform that action at this time.
0 commit comments