improve some error logs

...in particular, pass the error as a tracing param rather than directly
in the main error message. The new behavior is nicer with e.g.
OpenTelemetry.
This commit is contained in:
Scott Lamb
2023-08-03 15:42:41 -05:00
parent 9d07d24bc7
commit b9db9c11cc
12 changed files with 36 additions and 32 deletions

View File

@@ -95,8 +95,8 @@ impl std::os::unix::io::AsRawFd for Fd {
impl Drop for Fd {
fn drop(&mut self) {
if let Err(e) = nix::unistd::close(self.0) {
warn!("Unable to close sample file dir: {}", e);
if let Err(err) = nix::unistd::close(self.0) {
warn!(%err, "unable to close sample file dir");
}
}
}
@@ -236,9 +236,10 @@ impl SampleFileDir {
bail!(
Internal,
msg(
"metadata mismatch: {e}.\nexpected:\n{expected_meta:#?}\n\nactual:\n\
"metadata mismatch\nexpected:\n{expected_meta:#?}\n\nactual:\n\
{dir_meta:#?}",
),
source(e),
);
}
if expected_meta.in_progress_open.is_some() {