Skip to content

Commit 6719486

Browse files
authored
tracing: Elide redundant info in tracing contexts (#661)
The tracing context includes redundant information, particularly about the traffic target. This change modifies the accept stack to include both the source peer and target addresses in the `accept` context; and the target address has been removed from intermediate contexts, many of which can be moved to the debug level now.
1 parent 308a730 commit 6719486

File tree

5 files changed

+19
-38
lines changed

5 files changed

+19
-38
lines changed

linkerd/app/core/src/serve.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ where
3636
let span = info_span!(
3737
"accept",
3838
peer.addr = %addrs.peer(),
39+
target.addr = %addrs.target_addr(),
3940
);
4041

4142
// Ready the service before dispatching the request to it.

linkerd/app/inbound/src/endpoint.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -200,26 +200,12 @@ impl stack_tracing::GetSpan<()> for Target {
200200

201201
match self.http_version {
202202
http::Version::H2 => match self.dst.name_addr() {
203-
None => info_span!(
204-
"http2",
205-
port = %self.socket_addr.port(),
206-
),
207-
Some(name) => info_span!(
208-
"http2",
209-
%name,
210-
port = %self.socket_addr.port(),
211-
),
203+
None => info_span!("http2"),
204+
Some(name) => info_span!("http2", %name),
212205
},
213206
http::Version::Http1 => match self.dst.name_addr() {
214-
None => info_span!(
215-
"http1",
216-
port = %self.socket_addr.port(),
217-
),
218-
Some(name) => info_span!(
219-
"http1",
220-
%name,
221-
port = %self.socket_addr.port(),
222-
),
207+
None => info_span!("http1"),
208+
Some(name) => info_span!("http1", %name),
223209
},
224210
}
225211
}

linkerd/app/inbound/src/lib.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use linkerd2_app_core::{
2727
};
2828
use std::collections::HashMap;
2929
use tokio::sync::mpsc;
30-
use tracing::{info, info_span};
30+
use tracing::{debug_span, info};
3131

3232
pub mod endpoint;
3333
mod prevent_loop;
@@ -240,7 +240,7 @@ impl Config {
240240
),
241241
)
242242
.spawn_buffer(buffer_capacity)
243-
.instrument(|_: &Target| info_span!("profile"))
243+
.instrument(|_: &Target| debug_span!("profile"))
244244
.check_make_service::<Target, http::Request<_>>();
245245

246246
let forward = target
@@ -254,7 +254,7 @@ impl Config {
254254
),
255255
)
256256
.spawn_buffer(buffer_capacity)
257-
.instrument(|_: &Target| info_span!("forward"))
257+
.instrument(|_: &Target| debug_span!("forward"))
258258
.check_make_service::<Target, http::Request<http::boxed::Payload>>();
259259

260260
// Attempts to resolve the target as a service profile or, if that
@@ -355,13 +355,8 @@ impl Config {
355355
.box_http_request()
356356
.box_http_response(),
357357
)
358+
.instrument(|_: &_| debug_span!("source"))
358359
.check_new_service::<tls::accept::Meta, http::Request<_>>()
359-
.instrument(|src: &tls::accept::Meta| {
360-
info_span!(
361-
"source",
362-
target.addr = %src.addrs.target_addr(),
363-
)
364-
})
365360
.into_inner()
366361
.into_make_service();
367362

linkerd/app/outbound/src/lib.rs

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

3535
pub mod endpoint;
3636
mod prevent_loop;
@@ -335,7 +335,7 @@ impl Config {
335335
),
336336
)
337337
.spawn_buffer(buffer_capacity)
338-
.instrument(|t: &HttpEndpoint| info_span!("forward", peer.addr = %t.addr, peer.id = ?t.identity))
338+
.instrument(|t: &HttpEndpoint| debug_span!("forward", peer.id = ?t.identity))
339339
.check_make_service::<HttpEndpoint, http::Request<_>>();
340340

341341
// Attempts to route route request to a logical services that uses
@@ -416,7 +416,7 @@ impl Config {
416416
.push_make_thunk()
417417
.push(admit::AdmitLayer::new(prevent_loop))
418418
.push_map_target(TcpEndpoint::from)
419-
.instrument(|_: &SocketAddr| info_span!("forward")),
419+
.instrument(|_: &SocketAddr| debug_span!("forward")),
420420
is_discovery_rejected,
421421
)
422422
.into_new_service()
@@ -432,7 +432,7 @@ impl Config {
432432
.spawn_buffer(buffer_capacity)
433433
.check_make_service::<SocketAddr, ()>()
434434
.push(svc::layer::mk(tcp::Forward::new))
435-
.instrument(|a: &SocketAddr| info_span!("tcp", dst = %a))
435+
.instrument(|_: &SocketAddr| info_span!("tcp"))
436436
}
437437

438438
pub async fn build_server<E, R, C, H, S>(
@@ -524,9 +524,7 @@ impl Config {
524524
.box_http_response(),
525525
)
526526
.push(svc::layer::mk(http::normalize_uri::MakeNormalizeUri::new))
527-
.instrument(
528-
|addrs: &listen::Addrs| info_span!("source", target.addr = %addrs.target_addr()),
529-
)
527+
.instrument(|_: &listen::Addrs| debug_span!("source"))
530528
.check_new_service::<listen::Addrs, http::Request<_>>()
531529
.into_inner()
532530
.into_make_service();

linkerd/proxy/http/src/detect.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::{
1515
time::Duration,
1616
};
1717
use tower::{util::ServiceExt, Service};
18-
use tracing::{info_span, trace};
18+
use tracing::{debug, info_span, trace};
1919
use tracing_futures::Instrument;
2020

2121
type Server = hyper::server::conn::Http<trace::Executor>;
@@ -152,6 +152,7 @@ where
152152

153153
let timeout = tokio::time::delay_for(self.timeout);
154154
Box::pin(async move {
155+
trace!("Detecting");
155156
let (version, io) = tokio::select! {
156157
res = HttpVersion::detect(io) => { res? }
157158
() = timeout => {
@@ -161,7 +162,7 @@ where
161162

162163
match version {
163164
Some(HttpVersion::Http1) => {
164-
trace!("Handling as HTTP");
165+
debug!("Handling as HTTP");
165166
// Enable support for HTTP upgrades (CONNECT and websockets).
166167
let http = upgrade::Service::new(http, drain.clone());
167168
let conn = server
@@ -176,7 +177,7 @@ where
176177
}
177178

178179
Some(HttpVersion::H2) => {
179-
trace!("Handling as H2");
180+
debug!("Handling as H2");
180181
let conn = server
181182
.http2_only(true)
182183
.serve_connection(io, HyperServerSvc::new(http));
@@ -188,7 +189,7 @@ where
188189
}
189190

190191
None => {
191-
trace!("Forwarding TCP");
192+
debug!("Forwarding TCP");
192193
let release = drain.ignore_signal();
193194
tcp.oneshot(io).err_into::<Error>().await?;
194195
drop(release);

0 commit comments

Comments
 (0)