Skip to content

Commit ee08b62

Browse files
authored
Reduce tracing spans to the debug level (#730)
We currently set almost all span metadata at the info level, meaning that these spans are recorded/maintained for all connections/requests even though there are virtually no logs emitted with this metadata at the info level. This changes all of these spans to only be recorded at the debug level. Exceptions to this include the per-connection `accept` span and the top-level "inbound"|"outbound"|etc spans.
1 parent 4b48dbd commit ee08b62

File tree

10 files changed

+28
-27
lines changed

10 files changed

+28
-27
lines changed

linkerd/app/gateway/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use linkerd2_app_core::{
44
};
55
use linkerd2_app_inbound::endpoint as inbound;
66
use linkerd2_app_outbound as outbound;
7-
use tracing::info_span;
7+
use tracing::debug_span;
88

99
#[derive(Clone, Debug, Default)]
1010
pub struct Config {
@@ -51,7 +51,7 @@ impl Config {
5151
Allow(self.allow_discovery),
5252
))
5353
.check_new_service::<inbound::Target, http::Request<http::boxed::Payload>>()
54-
.instrument(|_: &inbound::Target| info_span!("gateway"))
54+
.instrument(|_: &inbound::Target| debug_span!("gateway"))
5555
.into_inner()
5656
}
5757
}

linkerd/app/inbound/src/endpoint.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,16 +273,16 @@ impl tap::Inspect for Target {
273273

274274
impl stack_tracing::GetSpan<()> for Target {
275275
fn get_span(&self, _: &()) -> tracing::Span {
276-
use tracing::info_span;
276+
use tracing::debug_span;
277277

278278
match self.http_version {
279279
http::Version::H2 => match self.dst.name_addr() {
280-
None => info_span!("http2"),
281-
Some(name) => info_span!("http2", %name),
280+
None => debug_span!("http2"),
281+
Some(name) => debug_span!("http2", %name),
282282
},
283283
http::Version::Http1 => match self.dst.name_addr() {
284-
None => info_span!("http1"),
285-
Some(name) => info_span!("http1", %name),
284+
None => debug_span!("http1"),
285+
Some(name) => debug_span!("http1", %name),
286286
},
287287
}
288288
}

linkerd/app/inbound/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use linkerd2_app_core::{
3030
};
3131
use std::{collections::HashMap, time::Duration};
3232
use tokio::{net::TcpStream, sync::mpsc};
33-
use tracing::{debug_span, info_span};
33+
use tracing::debug_span;
3434

3535
mod allow_discovery;
3636
pub mod endpoint;
@@ -105,7 +105,7 @@ impl Config {
105105
let tcp_forward = svc::stack(tcp_connect)
106106
.push_make_thunk()
107107
.push_on_response(svc::layer::mk(tcp::Forward::new))
108-
.instrument(|_: &_| info_span!("tcp"))
108+
.instrument(|_: &_| debug_span!("tcp"))
109109
.into_inner();
110110

111111
let accept = self.build_accept(
@@ -369,7 +369,7 @@ impl Config {
369369
)
370370
.push(svc::layer::mk(http::normalize_uri::MakeNormalizeUri::new))
371371
.push_map_target(|(_, accept): (_, TcpAccept)| accept)
372-
.instrument(|(v, _): &(http::Version, _)| info_span!("http", %v))
372+
.instrument(|(v, _): &(http::Version, _)| debug_span!("http", %v))
373373
.check_new_service::<(http::Version, TcpAccept), http::Request<_>>()
374374
.into_inner();
375375

linkerd/app/outbound/src/http/endpoint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use linkerd2_app_core::{
1212
svc, Error, TraceContext, CANONICAL_DST_HEADER, L5D_REQUIRE_ID,
1313
};
1414
use tokio::{io, sync::mpsc};
15-
use tracing::info_span;
15+
use tracing::debug_span;
1616

1717
pub fn stack<B, C>(
1818
config: &ConnectConfig,
@@ -69,6 +69,6 @@ where
6969
]))
7070
.push_on_response(svc::layers().box_http_response())
7171
.check_new::<Endpoint>()
72-
.instrument(|e: &Endpoint| info_span!("endpoint", peer.addr = %e.addr))
72+
.instrument(|e: &Endpoint| debug_span!("endpoint", peer.addr = %e.addr))
7373
.into_inner()
7474
}

linkerd/app/outbound/src/http/logical.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use linkerd2_app_core::{
77
proxy::{api_resolve::Metadata, core::Resolve, http},
88
retry, svc, Addr, Error, CANONICAL_DST_HEADER, DST_OVERRIDE_HEADER,
99
};
10-
use tracing::info_span;
10+
use tracing::debug_span;
1111

1212
pub fn stack<B, E, S, R>(
1313
config: &ProxyConfig,
@@ -74,8 +74,8 @@ where
7474
.into_new_service()
7575
.check_new_service::<Concrete, http::Request<_>>()
7676
.instrument(|c: &Concrete| match c.resolve.as_ref() {
77-
None => info_span!("concrete"),
78-
Some(addr) => info_span!("concrete", %addr),
77+
None => debug_span!("concrete"),
78+
Some(addr) => debug_span!("concrete", %addr),
7979
})
8080
.check_new_service::<Concrete, http::Request<_>>()
8181
// The concrete address is only set when the profile could be
@@ -116,7 +116,7 @@ where
116116
.push(http::strip_header::request::layer(DST_OVERRIDE_HEADER))
117117
.push(svc::layers().box_http_response()),
118118
)
119-
.instrument(|l: &Logical| info_span!("logical", dst = %l.addr()))
119+
.instrument(|l: &Logical| debug_span!("logical", dst = %l.addr()))
120120
.check_new_service::<Logical, http::Request<_>>()
121121
.into_inner()
122122
}

linkerd/app/outbound/src/ingress.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use linkerd2_app_core::{
1010
Addr, AddrMatch, Error, TraceContext,
1111
};
1212
use tokio::sync::mpsc;
13-
use tracing::info_span;
13+
use tracing::{debug_span, info_span};
1414

1515
/// Routes HTTP requests according to the l5d-dst-override header.
1616
///
@@ -93,6 +93,7 @@ where
9393
.spawn_buffer(buffer_capacity)
9494
.into_new_service()
9595
.check_new_service::<Target, http::Request<_>>()
96+
.instrument(|t: &Target| info_span!("target", dst = %t.dst))
9697
.push(svc::layer::mk(|inner| {
9798
svc::stack::NewRouter::new(TargetPerRequest::accept, inner)
9899
}))
@@ -120,7 +121,7 @@ where
120121
.check_new_service::<http::Accept, http::Request<_>>()
121122
.push(svc::layer::mk(http::normalize_uri::MakeNormalizeUri::new))
122123
.check_new_service::<http::Accept, http::Request<_>>()
123-
.instrument(|a: &http::Accept| info_span!("http", v = %a.protocol))
124+
.instrument(|a: &http::Accept| debug_span!("http", v = %a.protocol))
124125
.push_map_target(http::Accept::from)
125126
.check_new_service::<(http::Version, tcp::Accept), http::Request<_>>()
126127
.into_inner();

linkerd/app/outbound/src/server.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use linkerd2_app_core::{
1212
};
1313
use std::net::SocketAddr;
1414
use tokio::sync::mpsc;
15-
use tracing::info_span;
15+
use tracing::debug_span;
1616

1717
pub fn stack<R, P, C, H, S, I>(
1818
config: &Config,
@@ -88,7 +88,7 @@ where
8888
)
8989
.check_new_service::<http::Logical, http::Request<_>>()
9090
.push(svc::layer::mk(http::normalize_uri::MakeNormalizeUri::new))
91-
.instrument(|l: &http::Logical| info_span!("http", v = %l.protocol))
91+
.instrument(|l: &http::Logical| debug_span!("http", v = %l.protocol))
9292
.push_map_target(http::Logical::from)
9393
.check_new_service::<(http::Version, tcp::Logical), http::Request<_>>()
9494
.into_inner();
@@ -106,7 +106,7 @@ where
106106
.push_failfast(dispatch_timeout)
107107
.push_spawn_buffer_with_idle_timeout(buffer_capacity, cache_max_idle_age),
108108
)
109-
.instrument(|_: &_| info_span!("tcp"))
109+
.instrument(|_: &_| debug_span!("tcp"))
110110
.check_new_service::<tcp::Logical, transport::io::PrefixedIo<transport::metrics::SensorIo<I>>>()
111111
.into_inner();
112112

linkerd/app/outbound/src/tcp/balance.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use linkerd2_app_core::{
77
transport::io,
88
Addr, Error,
99
};
10-
use tracing::info_span;
10+
use tracing::debug_span;
1111

1212
/// Constructs a TCP load balancer.
1313
pub fn stack<C, R, I>(
@@ -41,7 +41,7 @@ where
4141
.push_make_thunk()
4242
.check_make_service::<Endpoint, ()>()
4343
.instrument(
44-
|t: &Endpoint| info_span!("endpoint", peer.addr = %t.addr, peer.id = ?t.identity),
44+
|t: &Endpoint| debug_span!("endpoint", peer.addr = %t.addr, peer.id = ?t.identity),
4545
)
4646
.check_make_service::<Endpoint, ()>()
4747
.push(resolve::layer(resolve, config.cache_max_idle_age * 2))

linkerd/proxy/http/src/h2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::{
1313
task::{Context, Poll},
1414
};
1515
use tokio::io::{AsyncRead, AsyncWrite};
16-
use tracing::{debug, info_span, trace_span};
16+
use tracing::{debug, debug_span, trace_span};
1717
use tracing_futures::Instrument;
1818

1919
#[derive(Copy, Clone, Debug, Default)]
@@ -107,7 +107,7 @@ where
107107

108108
Ok(Connection { tx })
109109
}
110-
.instrument(info_span!("h2")),
110+
.instrument(debug_span!("h2")),
111111
)
112112
}
113113
}

linkerd/service-profiles/src/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use tonic::{
2323
client::GrpcService,
2424
};
2525
use tower::retry::budget::Budget;
26-
use tracing::{debug, error, info_span, trace, warn};
26+
use tracing::{debug, debug_span, error, trace, warn};
2727
use tracing_futures::Instrument;
2828

2929
#[derive(Clone, Debug)]
@@ -256,7 +256,7 @@ where
256256
mut self: Pin<&mut Self>,
257257
cx: &mut Context<'_>,
258258
) -> Poll<Result<Profile, Error>> {
259-
let span = info_span!("poll_profile");
259+
let span = debug_span!("poll_profile");
260260
let _enter = span.enter();
261261

262262
loop {

0 commit comments

Comments
 (0)