Unverified Commit 9a6de1f5 authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Create `DisplayErrorContext` and use it in tracing statements (#1848)

* Add `DisplayErrorContext` to `aws-smithy-types`
* Apply `DisplayErrorContext` to all tracing statements
parent fa03f20b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ use std::net::IpAddr;

use aws_smithy_client::erase::boxclone::BoxCloneService;
use aws_smithy_http::endpoint::Endpoint;
use aws_smithy_types::error::display::DisplayErrorContext;
use aws_types::credentials;
use aws_types::credentials::{future, CredentialsError, ProvideCredentials};
use http::uri::{InvalidUri, Scheme};
@@ -182,7 +183,7 @@ impl Provider {
        let mut relative_uri = match relative_uri.parse::<Uri>() {
            Ok(uri) => uri,
            Err(invalid_uri) => {
                tracing::warn!(uri = ?invalid_uri, "invalid URI loaded from environment");
                tracing::warn!(uri = %DisplayErrorContext(&invalid_uri), "invalid URI loaded from environment");
                return Err(EcsConfigurationErr::InvalidRelativeUri {
                    err: invalid_uri,
                    uri: relative_uri,
+2 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
 * SPDX-License-Identifier: Apache-2.0
 */

use aws_smithy_types::error::display::DisplayErrorContext;
use aws_types::app_name::AppName;
use aws_types::os_shim_internal::Env;

@@ -32,7 +33,7 @@ impl EnvironmentVariableAppNameProvider {
            match AppName::new(name) {
                Ok(name) => Some(name),
                Err(err) => {
                    tracing::warn!(err = %err, "`AWS_SDK_UA_APP_ID` environment variable value was invalid");
                    tracing::warn!(err = %DisplayErrorContext(&err), "`AWS_SDK_UA_APP_ID` environment variable value was invalid");
                    None
                }
            }
+2 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ use aws_smithy_http::retry::ClassifyRetry;
use aws_smithy_http_tower::map_request::{
    AsyncMapRequestLayer, AsyncMapRequestService, MapRequestLayer, MapRequestService,
};
use aws_smithy_types::error::display::DisplayErrorContext;
use aws_smithy_types::retry::{ErrorKind, RetryKind};
use aws_types::os_shim_internal::{Env, Fs};

@@ -163,7 +164,7 @@ impl LazyClient {
            .get_or_init(|| async {
                let client = builder.clone().build().await;
                if let Err(err) = &client {
                    tracing::warn!(err = % err, "failed to create IMDS client")
                    tracing::warn!(err = %DisplayErrorContext(err), "failed to create IMDS client")
                }
                client
            })
+3 −4
Original line number Diff line number Diff line
@@ -12,10 +12,9 @@ use crate::imds;
use crate::imds::client::LazyClient;
use crate::meta::region::{future, ProvideRegion};
use crate::provider_config::ProviderConfig;

use aws_smithy_types::error::display::DisplayErrorContext;
use aws_types::os_shim_internal::Env;
use aws_types::region::Region;

use tracing::Instrument;

/// IMDSv2 Region Provider
@@ -57,7 +56,7 @@ impl ImdsRegionProvider {
                Some(Region::new(region))
            }
            Err(err) => {
                tracing::warn!(err = % err, "failed to load region from IMDS");
                tracing::warn!(err = %DisplayErrorContext(&err), "failed to load region from IMDS");
                None
            }
        }
+3 −3
Original line number Diff line number Diff line
@@ -3,9 +3,9 @@
 * SPDX-License-Identifier: Apache-2.0
 */

use std::borrow::Cow;

use aws_smithy_types::error::display::DisplayErrorContext;
use aws_types::credentials::{self, future, CredentialsError, ProvideCredentials};
use std::borrow::Cow;
use tracing::Instrument;

/// Credentials provider that checks a series of inner providers
@@ -86,7 +86,7 @@ impl CredentialsProviderChain {
                    tracing::debug!(provider = %name, context = %context, "provider in chain did not provide credentials");
                }
                Err(e) => {
                    tracing::warn!(provider = %name, error = %e, "provider failed to provide credentials");
                    tracing::warn!(provider = %name, error = %DisplayErrorContext(&e), "provider failed to provide credentials");
                    return Err(e);
                }
            }
Loading