Unverified Commit 0774950e authored by Landon James's avatar Landon James Committed by GitHub
Browse files

Add interceptor for collecting client metrics (#4021)

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->

## Description
<!--- Describe your changes in detail -->

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] For changes to the smithy-rs codegen or runtime crates, I have
created a changelog entry Markdown file in the `.changelog` directory,
specifying "client," "server," or both in the `applies_to` key.
- [ ] For changes to the AWS SDK, generated SDK code, or SDK runtime
crates, I have created a changelog entry Markdown file in the
`.changelog` directory, specifying "aws-sdk-rust" in the `applies_to`
key.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent 94dbe3b0
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -254,7 +254,7 @@ dependencies = [

[[package]]
name = "aws-smithy-eventstream"
version = "0.60.7"
version = "0.60.8"
dependencies = [
 "aws-smithy-types",
 "bytes",
@@ -298,6 +298,14 @@ dependencies = [
 "tracing",
]

[[package]]
name = "aws-smithy-observability"
version = "0.1.2"
dependencies = [
 "aws-smithy-runtime-api",
 "once_cell",
]

[[package]]
name = "aws-smithy-protocol-test"
version = "0.63.1"
@@ -317,11 +325,12 @@ dependencies = [

[[package]]
name = "aws-smithy-runtime"
version = "1.8.0"
version = "1.8.1"
dependencies = [
 "aws-smithy-async",
 "aws-smithy-http",
 "aws-smithy-http-client",
 "aws-smithy-observability",
 "aws-smithy-runtime-api",
 "aws-smithy-types",
 "bytes",
+11 −2
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"

[[package]]
name = "aws-config"
version = "1.6.0"
version = "1.6.1"
dependencies = [
 "aws-credential-types",
 "aws-runtime",
@@ -289,6 +289,14 @@ dependencies = [
 "aws-smithy-types",
]

[[package]]
name = "aws-smithy-observability"
version = "0.1.2"
dependencies = [
 "aws-smithy-runtime-api",
 "once_cell",
]

[[package]]
name = "aws-smithy-protocol-test"
version = "0.63.1"
@@ -316,11 +324,12 @@ dependencies = [

[[package]]
name = "aws-smithy-runtime"
version = "1.8.0"
version = "1.8.1"
dependencies = [
 "aws-smithy-async",
 "aws-smithy-http",
 "aws-smithy-http-client",
 "aws-smithy-observability",
 "aws-smithy-runtime-api",
 "aws-smithy-types",
 "bytes",
+1 −1
Original line number Diff line number Diff line
[package]
name = "aws-config"
version = "1.6.0"
version = "1.6.1"
authors = [
    "AWS Rust SDK Team <aws-sdk-rust@amazon.com>",
    "Russell Cohen <rcoh@amazon.com>",
+12 −3
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ use crate::json_credentials::{parse_json_credentials, JsonCredentials, Refreshab
use crate::provider_config::ProviderConfig;
use aws_credential_types::provider::{self, error::CredentialsError};
use aws_credential_types::Credentials;
use aws_smithy_runtime::client::metrics::MetricsRuntimePlugin;
use aws_smithy_runtime::client::orchestrator::operation::Operation;
use aws_smithy_runtime::client::retries::classifiers::{
    HttpStatusCodeClassifier, TransientErrorClassifier,
@@ -19,7 +20,7 @@ use aws_smithy_runtime::client::retries::classifiers::{
use aws_smithy_runtime_api::client::http::HttpConnectorSettings;
use aws_smithy_runtime_api::client::interceptors::context::{Error, InterceptorContext};
use aws_smithy_runtime_api::client::orchestrator::{
    HttpResponse, OrchestratorError, SensitiveOutput,
    HttpResponse, Metadata, OrchestratorError, SensitiveOutput,
};
use aws_smithy_runtime_api::client::result::SdkError;
use aws_smithy_runtime_api::client::retries::classifiers::ClassifyRetry;
@@ -88,6 +89,7 @@ impl Builder {
        path: impl Into<String>,
    ) -> HttpCredentialProvider {
        let provider_config = self.provider_config.unwrap_or_default();
        let path = path.into();

        let mut builder = Operation::builder()
            .service_name("HttpCredentialProvider")
@@ -105,7 +107,15 @@ impl Builder {
                let mut layer = Layer::new("SensitiveOutput");
                layer.store_put(SensitiveOutput);
                layer.freeze()
            }));
            }))
            .runtime_plugin(
                MetricsRuntimePlugin::builder()
                    .with_scope("aws_config::http_credential_provider")
                    .with_time_source(provider_config.time_source())
                    .with_metadata(Metadata::new(path.clone(), provider_name))
                    .build()
                    .expect("All required fields have been set"),
            );
        if let Some(http_client) = provider_config.http_client() {
            builder = builder.http_client(http_client);
        }
@@ -126,7 +136,6 @@ impl Builder {
        } else {
            builder = builder.no_retry();
        }
        let path = path.into();
        let operation = builder
            .serializer(move |input: HttpProviderAuth| {
                let mut http_req = http::Request::builder()
+10 −1
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ use crate::imds::client::token::TokenRuntimePlugin;
use crate::provider_config::ProviderConfig;
use crate::PKG_VERSION;
use aws_runtime::user_agent::{ApiMetadata, AwsUserAgent, UserAgentInterceptor};
use aws_smithy_runtime::client::metrics::MetricsRuntimePlugin;
use aws_smithy_runtime::client::orchestrator::operation::Operation;
use aws_smithy_runtime::client::retries::strategy::StandardRetryStrategy;
use aws_smithy_runtime_api::box_error::BoxError;
@@ -21,7 +22,7 @@ use aws_smithy_runtime_api::client::endpoint::{
};
use aws_smithy_runtime_api::client::interceptors::context::InterceptorContext;
use aws_smithy_runtime_api::client::orchestrator::{
    HttpRequest, OrchestratorError, SensitiveOutput,
    HttpRequest, Metadata, OrchestratorError, SensitiveOutput,
};
use aws_smithy_runtime_api::client::result::ConnectorError;
use aws_smithy_runtime_api::client::result::SdkError;
@@ -476,6 +477,14 @@ impl Builder {
                common_plugin,
                self.token_ttl.unwrap_or(DEFAULT_TOKEN_TTL),
            ))
            .runtime_plugin(
                MetricsRuntimePlugin::builder()
                    .with_scope("aws_config::imds_credentials")
                    .with_time_source(config.time_source())
                    .with_metadata(Metadata::new("get_credentials", "imds"))
                    .build()
                    .expect("All required fields have been set"),
            )
            .with_connection_poisoning()
            .serializer(|path| {
                Ok(HttpRequest::try_from(
Loading