Unverified Commit e54cc56a authored by ysaito1001's avatar ysaito1001 Committed by GitHub
Browse files

Add feature ID for S3 Transfer Manager (#3921)

## Motivation and Context
This PR introduces the `AwsSdkFeature` enum, which will be used for AWS
SDK-specific feature identifiers. For now, it includes a single ID for
the S3 Transfer Manager. This approach is similar to the existing
[SmithySdkFeature](https://github.com/smithy-lang/smithy-rs/blob/aac9becfd469e2479f68c61fd4c8074ddf755482/rust-runtime/aws-smithy-runtime/src/client/sdk_feature.rs#L10)
in terms of its module and crate structure (that is for generic client
but `AwsSdkFeature` is AWS specific); the `sdk_feature` module is hidden
as it is intended for internal use only.

## Testing
Added an integration test to verify tracking a business metric for
Transfer Manager. Since Transfer Manager is a high-level library, we do
not track its business metric directly within the `smithy-rs`
repository. Instead, [an s3
client](https://github.com/awslabs/aws-s3-transfer-manager-rs/blob/main/aws-s3-transfer-manager/src/config.rs#L21)
used in
[aws-s3-transfer-manager-rs](https://github.com/awslabs/aws-s3-transfer-manager-rs

)
can configure the s3 client as demonstrated in the integration test to
track the metric.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: default avatarZelda Hessler <zhessler@amazon.com>
parent aac9becf
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -138,7 +138,7 @@ dependencies = [


[[package]]
[[package]]
name = "aws-runtime"
name = "aws-runtime"
version = "1.4.3"
version = "1.4.4"
dependencies = [
dependencies = [
 "arbitrary",
 "arbitrary",
 "aws-credential-types",
 "aws-credential-types",
@@ -292,7 +292,7 @@ dependencies = [


[[package]]
[[package]]
name = "aws-smithy-runtime"
name = "aws-smithy-runtime"
version = "1.7.3"
version = "1.7.4"
dependencies = [
dependencies = [
 "aws-smithy-async",
 "aws-smithy-async",
 "aws-smithy-http",
 "aws-smithy-http",
+1 −1
Original line number Original line Diff line number Diff line
[package]
[package]
name = "aws-runtime"
name = "aws-runtime"
version = "1.4.3"
version = "1.4.4"
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>"]
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>"]
description = "Runtime support code for the AWS SDK. This crate isn't intended to be used directly."
description = "Runtime support code for the AWS SDK. This crate isn't intended to be used directly."
edition = "2021"
edition = "2021"
+4 −0
Original line number Original line Diff line number Diff line
@@ -38,6 +38,10 @@ pub mod invocation_id;
/// Supporting code for request metadata headers in the AWS SDK.
/// Supporting code for request metadata headers in the AWS SDK.
pub mod request_info;
pub mod request_info;


/// AWS SDK feature identifies.
#[doc(hidden)]
pub mod sdk_feature;

/// Interceptor that determines the clock skew between the client and service.
/// Interceptor that determines the clock skew between the client and service.
pub mod service_clock_skew;
pub mod service_clock_skew;


+18 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

use aws_smithy_types::config_bag::{Storable, StoreAppend};

/// IDs for the features that may be used in the AWS SDK
#[non_exhaustive]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum AwsSdkFeature {
    /// Indicates that an operation was called by the S3 Transfer Manager
    S3Transfer,
}

impl Storable for AwsSdkFeature {
    type Storer = StoreAppend<Self>;
}
+8 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ use aws_smithy_types::config_bag::ConfigBag;
use aws_types::app_name::AppName;
use aws_types::app_name::AppName;
use aws_types::os_shim_internal::Env;
use aws_types::os_shim_internal::Env;


use crate::sdk_feature::AwsSdkFeature;
use crate::user_agent::metrics::ProvideBusinessMetric;
use crate::user_agent::metrics::ProvideBusinessMetric;
use crate::user_agent::{AdditionalMetadata, ApiMetadata, AwsUserAgent, InvalidMetadataValue};
use crate::user_agent::{AdditionalMetadata, ApiMetadata, AwsUserAgent, InvalidMetadataValue};


@@ -138,6 +139,13 @@ impl Intercept for UserAgentInterceptor {
                .map(|m| ua.add_business_metric(m));
                .map(|m| ua.add_business_metric(m));
        }
        }


        let aws_sdk_features = cfg.load::<AwsSdkFeature>();
        for aws_sdk_feature in aws_sdk_features {
            aws_sdk_feature
                .provide_business_metric()
                .map(|m| ua.add_business_metric(m));
        }

        let maybe_connector_metadata = runtime_components
        let maybe_connector_metadata = runtime_components
            .http_client()
            .http_client()
            .and_then(|c| c.connector_metadata());
            .and_then(|c| c.connector_metadata());
Loading