Skip to content

Commit 23be547

Browse files
hawkwolix0r
authored andcommitted
tracing: use Options as tracing values (#1299)
Tracing 0.1.29 added a `tracing::field::Value` implementation for `Option<T> where T: Value`. This means that `Option`s can now be used as structured field values, rather than recording them with `fmt::Debug`. When the `Option` is `None`, the field will simply be skipped. This allows us to make a bunch of existing code simpler. There are a number of places where we create one span or event if some value is `Some`, and a different span/event without that field if the value is `None`. This can be changed to just use the `Option` as a field value directly. I'm almost certain I missed some of those places, but I changed the ones I could find. This also updates `tracing` to 0.1.29, of course. (cherry picked from commit 87434bc) Signed-off-by: Oliver Gould <[email protected]>
1 parent a271b64 commit 23be547

File tree

41 files changed

+67
-64
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+67
-64
lines changed

Cargo.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,9 +2310,9 @@ dependencies = [
23102310

23112311
[[package]]
23122312
name = "tracing"
2313-
version = "0.1.28"
2313+
version = "0.1.29"
23142314
source = "registry+https://github.com/rust-lang/crates.io-index"
2315-
checksum = "84f96e095c0c82419687c20ddf5cb3eadb61f4e1405923c9dc8e53a1adacbda8"
2315+
checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105"
23162316
dependencies = [
23172317
"cfg-if",
23182318
"log",
@@ -2323,9 +2323,9 @@ dependencies = [
23232323

23242324
[[package]]
23252325
name = "tracing-attributes"
2326-
version = "0.1.16"
2326+
version = "0.1.18"
23272327
source = "registry+https://github.com/rust-lang/crates.io-index"
2328-
checksum = "98863d0dd09fa59a1b79c6750ad80dbda6b75f4e71c437a6a1a8cb91a8bcbd77"
2328+
checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
23292329
dependencies = [
23302330
"proc-macro2",
23312331
"quote",
@@ -2334,9 +2334,9 @@ dependencies = [
23342334

23352335
[[package]]
23362336
name = "tracing-core"
2337-
version = "0.1.20"
2337+
version = "0.1.21"
23382338
source = "registry+https://github.com/rust-lang/crates.io-index"
2339-
checksum = "46125608c26121c81b0c6d693eab5a420e416da7e43c426d2e8f7df8da8a3acf"
2339+
checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4"
23402340
dependencies = [
23412341
"lazy_static",
23422342
]

linkerd/addr/fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cargo-fuzz = true
1212
libfuzzer-sys = "0.4"
1313
linkerd-addr = { path = ".." }
1414
linkerd-tracing = { path = "../../tracing", features = ["ansi"] }
15-
tracing = "0.1.26"
15+
tracing = "0.1.29"
1616

1717
# Prevent this from interfering with workspaces
1818
[workspace]

linkerd/app/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ tokio = { version = "1", features = ["rt"] }
2929
tokio-stream = { version = "0.1.7", features = ["time", "sync"] }
3030
tonic = { version = "0.5", default-features = false, features = ["prost"] }
3131
tower = "0.4.8"
32-
tracing = "0.1.28"
32+
tracing = "0.1.29"

linkerd/app/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ thiserror = "1.0"
6565
tokio = { version = "1", features = ["macros", "sync", "parking_lot"]}
6666
tokio-stream = { version = "0.1.7", features = ["time"] }
6767
tonic = { version = "0.5", default-features = false, features = ["prost"] }
68-
tracing = "0.1.28"
68+
tracing = "0.1.29"
6969
parking_lot = "0.11"
7070
pin-project = "1"
7171

linkerd/app/gateway/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ linkerd-app-outbound = { path = "../outbound" }
1515
thiserror = "1.0"
1616
tokio = { version = "1", features = ["sync"] }
1717
tower = { version = "0.4.8", default-features = false }
18-
tracing = "0.1.28"
18+
tracing = "0.1.29"
1919

2020
[dev-dependencies]
2121
tokio = { version = "1", features = ["rt", "macros"] }

linkerd/app/inbound/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ thiserror = "1.0"
2222
tokio = { version = "1", features = ["sync"] }
2323
tonic = { version = "0.5", default-features = false }
2424
tower = { version = "0.4.8", features = ["util"] }
25-
tracing = "0.1.28"
25+
tracing = "0.1.29"
2626

2727
[target.'cfg(fuzzing)'.dependencies]
2828
hyper = { version = "0.14.13", features = ["http1", "http2"] }

linkerd/app/inbound/fuzz/test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
set +x
3+
CARGO=$(which cargo)
4+
timeout 10m $CARGO fuzz build

linkerd/app/inbound/src/http/router.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,12 @@ impl<C> Inbound<C> {
219219
.push(http::BoxResponse::layer()),
220220
)
221221
.check_new_service::<Logical, http::Request<http::BoxBody>>()
222-
.instrument(|t: &Logical| match (t.http, t.logical.as_ref()) {
223-
(http::Version::H2, None) => debug_span!("http2"),
224-
(http::Version::H2, Some(name)) => debug_span!("http2", %name),
225-
(http::Version::Http1, None) => debug_span!("http1"),
226-
(http::Version::Http1, Some(name)) => debug_span!("http1", %name),
222+
.instrument(|t: &Logical| {
223+
let name = t.logical.as_ref().map(tracing::field::display);
224+
match t.http {
225+
http::Version::H2 => debug_span!("http2", name),
226+
http::Version::Http1 => debug_span!("http1", name),
227+
}
227228
})
228229
// Routes each request to a target, obtains a service for that target, and
229230
// dispatches the request. NewRouter moves the NewService into the service type, so

linkerd/app/integration/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ tokio-stream = { version = "0.1.7", features = ["sync"] }
3636
tokio-rustls = "0.22"
3737
tower = { version = "0.4.8", default-features = false }
3838
tonic = { version = "0.5", default-features = false }
39-
tracing = "0.1.28"
39+
tracing = "0.1.29"
4040
webpki = "0.21"
4141
tracing-subscriber = { version = "0.2", default-features = false, features = ["fmt"] }
4242

linkerd/app/outbound/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ parking_lot = "0.11"
2525
thiserror = "1.0"
2626
tokio = { version = "1", features = ["sync"] }
2727
tower = { version = "0.4.8", features = ["util"] }
28-
tracing = "0.1.28"
28+
tracing = "0.1.29"
2929
pin-project = "1"
3030

3131
[dev-dependencies]

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,14 @@ impl<B, F: TryFuture<Ok = http::Response<B>>> Future for ResponseFuture<F> {
9090
if proxy_conn == "close" {
9191
match rsp.extensions().get::<tls::ConditionalClientTls>() {
9292
Some(tls::ConditionalClientTls::Some(_)) => {
93-
if let Some(error) = rsp
94-
.headers()
95-
.get(L5D_PROXY_ERROR)
96-
.and_then(|v| v.to_str().ok())
97-
{
98-
tracing::info!(%error, "Closing application connection for remote proxy");
99-
} else {
100-
tracing::info!("Closing application connection for remote proxy");
101-
}
93+
tracing::info!(
94+
error = rsp
95+
.headers()
96+
.get(L5D_PROXY_ERROR)
97+
.and_then(|v| v.to_str().ok())
98+
.map(tracing::field::display),
99+
"Closing application connection for remote proxy"
100+
);
102101

103102
if rsp.version() == http::Version::HTTP_11 {
104103
// If the response is HTTP/1.1, we need to send a Connection: close

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use linkerd_app_core::{
88
resolve::map_endpoint,
99
tcp,
1010
},
11-
svc, Conditional, Error, Infallible,
11+
svc, Error, Infallible,
1212
};
1313
use tracing::debug_span;
1414

@@ -66,13 +66,12 @@ where
6666

6767
connect
6868
.push_make_thunk()
69-
.instrument(|t: &Endpoint| match t.tls.as_ref() {
70-
Conditional::Some(tls) => {
71-
debug_span!("endpoint", server.addr = %t.addr, server.id = ?tls.server_id)
72-
}
73-
Conditional::None(_) => {
74-
debug_span!("endpoint", server.addr = %t.addr)
75-
}
69+
.instrument(|t: &Endpoint| {
70+
debug_span!(
71+
"endpoint",
72+
server.addr = %t.addr,
73+
server.id = t.tls.value().map(|tls| tracing::field::display(&tls.server_id)),
74+
)
7675
})
7776
.push(resolve::layer(resolve, config.proxy.cache_max_idle_age * 2))
7877
.push_on_service(

linkerd/app/test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ tokio = { version = "1", features = ["io-util", "net", "rt", "sync"]}
3030
tokio-test = "0.4"
3131
tokio-stream = { version = "0.1.7", features = ["sync"] }
3232
tower = { version = "0.4.8", default-features = false}
33-
tracing = "0.1.28"
33+
tracing = "0.1.29"
3434
tracing-subscriber = { version = "0.2.24", features = ["env-filter", "fmt"], default-features = false }
3535
thiserror = "1"

linkerd/cache/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ linkerd-stack = { path = "../stack" }
1313
parking_lot = "0.11"
1414
tokio = { version = "1", default-features = false, features = ["rt", "sync", "time"] }
1515
tower = { version = "0.4.8", default-features = false, features = ["util"] }
16-
tracing = "0.1.28"
16+
tracing = "0.1.29"
1717

1818
[dev-dependencies]
1919
tokio = { version = "1", default-features = false, features = ["macros", "test-util", "time"] }

linkerd/detect/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ linkerd-stack = { path = "../stack" }
1515
tokio = { version = "1", features = ["time"] }
1616
thiserror = "1.0"
1717
tower = "0.4.8"
18-
tracing = "0.1.28"
18+
tracing = "0.1.29"

linkerd/dns/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ futures = { version = "0.3", default-features = false }
1111
linkerd-dns-name = { path = "./name" }
1212
linkerd-error = { path = "../error" }
1313
thiserror = "1.0"
14-
tracing = "0.1.28"
14+
tracing = "0.1.29"
1515
trust-dns-resolver = "0.21.0-alpha.3"
1616
tokio = { version = "1", features = ["rt", "sync", "time"] }
1717
pin-project = "1"

linkerd/dns/fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cargo-fuzz = true
1313
libfuzzer-sys = "0.4"
1414
linkerd-dns = { path = ".." }
1515
tokio = { version = "1", features = ["rt", "time", "io-util"] }
16-
tracing = "0.1.26"
16+
tracing = "0.1.29"
1717
linkerd-tracing = { path = "../../tracing", features = ["ansi"] }
1818

1919
# Prevent this from interfering with workspaces

linkerd/duplex/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ bytes = "1"
1111
futures = { version = "0.3", default-features = false }
1212
tokio = { version = "1", features = ["io-util"] }
1313
pin-project = "1"
14-
tracing = "0.1.28"
14+
tracing = "0.1.29"
1515
linkerd-io = { path = "../io" }

linkerd/http-metrics/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ linkerd-stack = { path = "../stack" }
1919
parking_lot = "0.11"
2020
pin-project = "1"
2121
tower = "0.4.8"
22-
tracing = "0.1.28"
22+
tracing = "0.1.29"

linkerd/http-retry/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ http = "0.2"
1414
linkerd-error = { path = "../error" }
1515
pin-project = "1"
1616
parking_lot = "0.11"
17-
tracing = "0.1.28"
17+
tracing = "0.1.29"
1818
thiserror = "1"
1919

2020
[dev-dependencies]

linkerd/identity/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ linkerd-dns-name = { path = "../dns/name" }
1414
ring = "0.16.19"
1515
thiserror = "1.0"
1616
tokio-rustls = "0.22"
17-
tracing = "0.1.28"
17+
tracing = "0.1.29"
1818
untrusted = "0.7"
1919
webpki = "=0.21.4"
2020

linkerd/metrics/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ hyper = { version = "0.14.13", features = ["http1", "http2"] }
1919
linkerd-stack = { path = "../stack", optional = true }
2020
parking_lot = "0.11"
2121
tokio = { version = "1", features = ["time"], optional = true }
22-
tracing = "0.1.28"
22+
tracing = "0.1.29"
2323

2424
[dev-dependencies]
2525
quickcheck = { version = "1", default-features = false }

linkerd/opencensus/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ tonic = { version = "0.5", default-features = false, features = ["prost", "codeg
1717
tower = { version = "0.4.8", default-features = false }
1818
tokio = { version = "1", features = ["macros", "sync", "time"] }
1919
tokio-stream = { version = "0.1.7", features = ["sync"] }
20-
tracing = "0.1.28"
20+
tracing = "0.1.29"

linkerd/proxy/api-resolve/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ pin-project = "1"
2727
prost = "0.8"
2828
tonic = { version = "0.5", default-features = false }
2929
tower = { version = "0.4.8", default-features = false }
30-
tracing = "0.1.28"
30+
tracing = "0.1.29"

linkerd/proxy/discover/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ linkerd-stack = { path = "../../stack" }
1818
tokio = { version = "1", features = ["sync", "time"] }
1919
tokio-util = "0.6.8"
2020
tower = { version = "0.4.8", features = ["discover"] }
21-
tracing = "0.1.28"
21+
tracing = "0.1.29"
2222
pin-project = "1"
2323

2424
[dev-dependencies]

linkerd/proxy/dns-resolve/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ linkerd-stack = { path = "../../stack" }
1919
tokio = { version = "1", features = ["sync"] }
2020
tokio-stream = { version = "0.1.7", features = ["sync"]}
2121
tower = "0.4.8"
22-
tracing = "0.1.28"
22+
tracing = "0.1.29"

linkerd/proxy/http/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ rand = "0.8"
3333
thiserror = "1.0"
3434
tokio = { version = "1", features = ["time", "rt"] }
3535
tower = { version = "0.4.8", default-features = false, features = ["balance", "load", "discover"] }
36-
tracing = "0.1.28"
36+
tracing = "0.1.29"
3737
try-lock = "0.2"
3838
pin-project = "1"
3939

linkerd/proxy/identity/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ linkerd-tls = { path = "../../tls" }
2020
thiserror = "1"
2121
tokio = { version = "1", features = ["time", "sync"] }
2222
tonic = { version = "0.5", default-features = false }
23-
tracing = "0.1.28"
23+
tracing = "0.1.29"
2424
http-body = "0.4"
2525
pin-project = "1"

linkerd/proxy/tap/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ thiserror = "1.0"
2929
tokio = { version = "1", features = ["time"]}
3030
tower = { version = "0.4.8", default-features = false }
3131
tonic = { version = "0.5", default-features = false }
32-
tracing = "0.1.28"
32+
tracing = "0.1.29"
3333
pin-project = "1"
3434

3535
[dev-dependencies]

linkerd/proxy/transport/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ linkerd-stack = { path = "../../stack" }
1616
socket2 = "0.4"
1717
tokio = { version = "1", features = ["macros", "net"] }
1818
tokio-stream = { version = "0.1", features = ["net"] }
19-
tracing = "0.1.28"
19+
tracing = "0.1.29"
2020

2121
[target.'cfg(target_os = "linux")'.dependencies]
2222
libc = "0.2"

linkerd/reconnect/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ linkerd-error = { path = "../error" }
1111
linkerd-stack = { path = "../stack" }
1212
futures = { version = "0.3", default-features = false }
1313
tower = { version = "0.4.8", default-features = false }
14-
tracing = "0.1.28"
14+
tracing = "0.1.29"
1515
pin-project = "1"
1616

1717
[dev-dependencies]

linkerd/retry/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ linkerd-error = { path = "../error" }
1111
linkerd-stack = { path = "../stack" }
1212
pin-project = "1"
1313
tower = { version = "0.4.8", default-features = false, features = ["retry"] }
14-
tracing = "0.1.28"
14+
tracing = "0.1.29"

linkerd/service-profiles/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ tokio-stream = { version = "0.1", features = ["sync"] }
3333
tonic = { version = "0.5", default-features = false }
3434
tower = { version = "0.4.8", features = [ "ready-cache", "retry", "util"] }
3535
thiserror = "1"
36-
tracing = "0.1.28"
36+
tracing = "0.1.29"
3737
pin-project = "1"
3838

3939
[dev-dependencies]

linkerd/signal/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ publish = false
88

99
[dependencies]
1010
tokio = { version = "1", features = ["macros", "signal"] }
11-
tracing = "0.1.28"
11+
tracing = "0.1.29"

linkerd/stack/tracing/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ futures = { version = "0.3", default-features = false }
1111
linkerd-error = { path = "../../error" }
1212
linkerd-stack = { path = ".." }
1313
tower = "0.4.8"
14-
tracing = "0.1.28"
14+
tracing = "0.1.29"

linkerd/tls/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ thiserror = "1.0"
2020
tokio = { version = "1", features = ["macros", "time"] }
2121
tokio-rustls = "0.22"
2222
tower = "0.4.8"
23-
tracing = "0.1.28"
23+
tracing = "0.1.29"
2424
webpki = "0.21"
2525
untrusted = "0.7"
2626

linkerd/tracing/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ansi = ["tracing-subscriber/ansi"]
1313
[dependencies]
1414
linkerd-error = { path = "../error" }
1515
tokio = { version = "1", features = ["time"] }
16-
tracing = "0.1.28"
16+
tracing = "0.1.29"
1717
tracing-log = "0.1.2"
1818

1919
[dependencies.tracing-subscriber]

linkerd/transport-header/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ linkerd-io = { path = "../io" }
1616
linkerd-stack = { path = "../stack" }
1717
prost = "0.8"
1818
tokio = { version = "1", features = ["time"] }
19-
tracing = "0.1.28"
19+
tracing = "0.1.29"
2020

2121
[build-dependencies]
2222
prost-build = { version = "0.8", default-features = false }

linkerd/transport-header/fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ arbitrary = { version = "1", features = ["derive"] }
1313
libfuzzer-sys = { version = "0.4.2", features = ["arbitrary-derive"] }
1414
linkerd-transport-header = { path = ".." }
1515
tokio = { version = "1", features = ["full"] }
16-
tracing = "0.1.26"
16+
tracing = "0.1.29"
1717
linkerd-tracing = { path = "../../tracing", features = ["ansi"] }
1818

1919
# Prevent this from interfering with workspaces

linkerd/transport-metrics/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ linkerd-metrics = { path = "../metrics" }
1515
linkerd-stack = { path = "../stack" }
1616
parking_lot = "0.11"
1717
pin-project = "1"
18-
tracing = "0.1.28"
18+
tracing = "0.1.29"

0 commit comments

Comments
 (0)