From 50c825b5dbd3471bc731d7a8fbeaae78fe5a2321 Mon Sep 17 00:00:00 2001 From: Landon James Date: Thu, 30 May 2024 10:47:29 -0700 Subject: [PATCH] Reducing verbosity of various logs (#3664) ## Motivation and Context Our logs had several entries that were extremely verbose and made them harder to sort through. This change aims to reduce the verbosity of those logs to something more manageable. ## Description - Removed the logging of the full IMDS Client struct, replaced with a message that it was truncated - Removed logging the full `Configbag` in a couple places in `RuntimeComponentsBuilder` - Removed logging of full `ProvideCredentials` objects in the CredentialsProviderChain` and replaced with just their names There are some verbose logs I did not remove because I was not sure of their usefulness. Most notably the `PartitionResolver` struct logs several hundred lines of region information each time it appears. Happy to truncate that as well if those logs aren't too helpful. ## Testing This was tested locally by running the SDK [logging example](https://docs.aws.amazon.com/sdk-for-rust/latest/dg/logging.html) code with `RUST_LOG=trace` prepended to the `cargo run` command. For comparison, when saved as a .txt file, the old logs take up `2.8MB` and the new logs take `273KB` for the same operation. ## Checklist - [x] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --- CHANGELOG.next.toml | 8 +++++++- aws/rust-runtime/aws-config/Cargo.toml | 2 +- aws/rust-runtime/aws-config/src/imds/region.rs | 11 ++++++++++- .../aws-config/src/meta/credentials/chain.rs | 17 ++++++++++++++++- rust-runtime/aws-smithy-runtime-api/Cargo.toml | 2 +- .../src/client/runtime_components.rs | 2 -- 6 files changed, 35 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index fc4c4c2578..9070a3f613 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -9,4 +9,10 @@ # message = "Fix typos in module documentation for generated crates" # references = ["smithy-rs#920"] # meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"} -# author = "rcoh" \ No newline at end of file +# author = "rcoh" + +[[smithy-rs]] +message = "Reduce verbosity of various debug logs" +references = ["smithy-rs#3664"] +meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client"} +author = "landonxjames" diff --git a/aws/rust-runtime/aws-config/Cargo.toml b/aws/rust-runtime/aws-config/Cargo.toml index 697476a911..2280cd8f56 100644 --- a/aws/rust-runtime/aws-config/Cargo.toml +++ b/aws/rust-runtime/aws-config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aws-config" -version = "1.5.0" +version = "1.5.1" authors = [ "AWS Rust SDK Team ", "Russell Cohen ", diff --git a/aws/rust-runtime/aws-config/src/imds/region.rs b/aws/rust-runtime/aws-config/src/imds/region.rs index 213e4a5c36..c837438a62 100644 --- a/aws/rust-runtime/aws-config/src/imds/region.rs +++ b/aws/rust-runtime/aws-config/src/imds/region.rs @@ -14,17 +14,26 @@ 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 std::fmt::Debug; use tracing::Instrument; /// IMDSv2 Region Provider /// /// This provider is included in the default region chain, so it does not need to be used manually. -#[derive(Debug)] pub struct ImdsRegionProvider { client: Client, env: Env, } +impl Debug for ImdsRegionProvider { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ImdsRegionProvider") + .field("client", &"IMDS client truncated for readability") + .field("env", &self.env) + .finish() + } +} + const REGION_PATH: &str = "/latest/meta-data/placement/region"; impl ImdsRegionProvider { diff --git a/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs b/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs index 884c016bf1..7d657f7f6c 100644 --- a/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs +++ b/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs @@ -9,6 +9,7 @@ use aws_credential_types::{ }; use aws_smithy_types::error::display::DisplayErrorContext; use std::borrow::Cow; +use std::fmt::Debug; use tracing::Instrument; /// Credentials provider that checks a series of inner providers @@ -31,11 +32,25 @@ use tracing::Instrument; /// .or_else("Profile", ProfileFileCredentialsProvider::builder().build()); /// # } /// ``` -#[derive(Debug)] pub struct CredentialsProviderChain { providers: Vec<(Cow<'static, str>, Box)>, } +impl Debug for CredentialsProviderChain { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("CredentialsProviderChain") + .field( + "providers", + &self + .providers + .iter() + .map(|provider| &provider.0) + .collect::>>(), + ) + .finish() + } +} + impl CredentialsProviderChain { /// Create a `CredentialsProviderChain` that begins by evaluating this provider pub fn first_try( diff --git a/rust-runtime/aws-smithy-runtime-api/Cargo.toml b/rust-runtime/aws-smithy-runtime-api/Cargo.toml index f4c5937f0e..4334499fc7 100644 --- a/rust-runtime/aws-smithy-runtime-api/Cargo.toml +++ b/rust-runtime/aws-smithy-runtime-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aws-smithy-runtime-api" -version = "1.6.1" +version = "1.6.2" authors = ["AWS Rust SDK Team ", "Zelda Hessler "] description = "Smithy runtime types." edition = "2021" diff --git a/rust-runtime/aws-smithy-runtime-api/src/client/runtime_components.rs b/rust-runtime/aws-smithy-runtime-api/src/client/runtime_components.rs index 6ec7b540e0..4ee81363f1 100644 --- a/rust-runtime/aws-smithy-runtime-api/src/client/runtime_components.rs +++ b/rust-runtime/aws-smithy-runtime-api/src/client/runtime_components.rs @@ -483,7 +483,6 @@ impl RuntimeComponents { }; } - tracing::trace!(runtime_components=?self, cfg=?cfg, "validating final config"); for validator in self.config_validators() { validator.validate_final_config(self, cfg)?; } @@ -875,7 +874,6 @@ impl RuntimeComponentsBuilder { }; } - tracing::trace!(runtime_components=?self, cfg=?cfg, "validating base client config"); for validator in self.config_validators() { validator.validate_base_client_config(self, cfg)?; }