Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracing: record errors as &dyn Errors when possible #1606

Merged
merged 2 commits into from
Apr 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2566,9 +2566,9 @@ dependencies = [

[[package]]
name = "tracing-core"
version = "0.1.22"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23"
checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f"
dependencies = [
"lazy_static",
"valuable",
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/admin/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ where
let rsp = match level {
Some(level) => {
level::serve(&level, req).await.unwrap_or_else(|error| {
tracing::error!(%error, "Failed to get/set tracing level");
tracing::error!(error, "Failed to get/set tracing level");
Self::internal_error_rsp(error)
})
}
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/admin/src/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl errors::HttpRescue<Error> for Rescue {
return Ok(errors::SyntheticHttpResponse::permission_denied(error));
}

tracing::warn!(%error, "Unexpected error");
tracing::warn!(error, "Unexpected error");
Ok(errors::SyntheticHttpResponse::unexpected_error())
}
}
2 changes: 1 addition & 1 deletion linkerd/app/core/src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Config {
let resolve_backoff = {
let backoff = self.connect.backoff;
move |error: Error| {
warn!(%error, "Failed to resolve control-plane component");
warn!(error, "Failed to resolve control-plane component");
if let Some(e) = error.downcast_ref::<dns::ResolveError>() {
if let dns::ResolveErrorKind::NoRecordsFound {
negative_ttl: Some(ttl_secs),
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/core/src/errors/respond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ where
};

let rsp = info_span!("rescue", client.addr = %self.client_addr()).in_scope(|| {
tracing::info!(%error, "Request failed");
tracing::info!(error, "Request failed");
self.rescue.rescue(error)
})?;

Expand Down
6 changes: 3 additions & 3 deletions linkerd/app/core/src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub async fn serve<M, S, I, A>(
let (addrs, io) = match conn {
Ok(conn) => conn,
Err(error) => {
warn!(%error, "Server failed to accept connection");
warn!(error, "Server failed to accept connection");
continue;
}
};
Expand All @@ -60,7 +60,7 @@ pub async fn serve<M, S, I, A>(
debug!(%reason, "Connection closed")
}
Err(error) => {
info!(%error, client.addr = %client_addr, "Connection closed")
info!(error, client.addr = %client_addr, "Connection closed")
}
}
// Hold the service until the connection is complete. This
Expand All @@ -69,7 +69,7 @@ pub async fn serve<M, S, I, A>(
drop(accept);
}
Err(error) => {
warn!(%error, client.addr = %client_addr, "Server failed to become ready");
warn!(error, client.addr = %client_addr, "Server failed to become ready");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/inbound/src/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl errors::HttpRescue<Error> for ServerRescue {
return Err(error);
}

tracing::warn!(%error, "Unexpected error");
tracing::warn!(error, "Unexpected error");
Ok(errors::SyntheticHttpResponse::unexpected_error())
}
}
9 changes: 6 additions & 3 deletions linkerd/app/integration/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,12 @@ where
let span = tracing::debug_span!("conn", %addr);
let serve = http.serve_connection(sock, svc.clone());
let f = async move {
serve
.await
.map_err(|error| tracing::error!(%error, "serving connection failed."))?;
serve.await.map_err(|error| {
tracing::error!(
error = &error as &dyn std::error::Error,
"serving connection failed."
)
})?;
Ok::<(), ()>(())
};
tokio::spawn(cancelable(drain.clone(), f).instrument(span.or_current()));
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/outbound/src/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl errors::HttpRescue<Error> for ServerRescue {
return Err(error);
}

tracing::warn!(%error, "Unexpected error");
tracing::warn!(error, "Unexpected error");
Ok(errors::SyntheticHttpResponse::unexpected_error())
}
}
2 changes: 1 addition & 1 deletion linkerd/app/src/dst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Recover<Error> for BackoffUnlessInvalidArgument {
return Err(error);
}

tracing::trace!(%error, "Recovering");
tracing::trace!(error, "Recovering");
Ok(self.0.stream())
}
}
Expand Down
2 changes: 1 addition & 1 deletion linkerd/proxy/discover/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ where
Some(Ok(up)) => up,
Some(Err(e)) => {
let error: Error = e.into();
warn!(%error, "Discovery task failed");
warn!(error, "Discovery task failed");
return Poll::Ready(());
}
None => {
Expand Down
2 changes: 1 addition & 1 deletion linkerd/proxy/identity-client/src/certify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Certify {
curr_expiry = expiry
}
Err(error) => {
error!(%error, "Failed to obtain identity");
error!(error, "Failed to obtain identity");
}
}

Expand Down
4 changes: 2 additions & 2 deletions linkerd/reconnect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ where
Err(e) => {
// If the service fails, try to recover.
let error: Error = e.into();
warn!(%error, "Service failed");
warn!(error, "Service failed");
let backoff = self.recover.recover(error)?;
debug!("Recovering");
State::Disconnected {
Expand All @@ -137,7 +137,7 @@ where
// If the service cannot be built, try to recover using
// the existing backoff.
let error: Error = e.into();
warn!(%error, "Failed to connect");
warn!(error, "Failed to connect");
let new_backoff = self.recover.recover(error)?;
debug!("Recovering");
State::Disconnected {
Expand Down
2 changes: 1 addition & 1 deletion linkerd/service-profiles/src/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ where
self.0.get_profile(dst).or_else(|e| {
let error: Error = e.into();
if crate::DiscoveryRejected::is_rejected(error.as_ref()) {
debug!(%error, "Handling rejected discovery");
debug!(error, "Handling rejected discovery");
return future::ok(None);
}

Expand Down