AWS SDK

AWS SDK

rev. 703af49b7608996376f0414c2c5111bb1f2461f0

Files changed:

tmp-codegen-diff/aws-sdk/sdk/transcribestreaming/src/config.rs

@@ -1278,1278 +1337,1338 @@
 1298   1298   
        runtime_components.push_interceptor(crate::sdk_feature_tracker::retry_mode::RetryModeFeatureTrackerInterceptor::new());
 1299   1299   
        runtime_components.push_interceptor(::aws_runtime::service_clock_skew::ServiceClockSkewInterceptor::new());
 1300   1300   
        runtime_components.push_interceptor(::aws_runtime::request_info::RequestInfoInterceptor::new());
 1301   1301   
        runtime_components.push_interceptor(::aws_runtime::user_agent::UserAgentInterceptor::new());
 1302   1302   
        runtime_components.push_interceptor(::aws_runtime::invocation_id::InvocationIdInterceptor::new());
 1303   1303   
        runtime_components.push_interceptor(::aws_runtime::recursion_detection::RecursionDetectionInterceptor::new());
 1304   1304   
        runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
 1305   1305   
            ::aws_runtime::auth::sigv4::SigV4AuthScheme::new(),
 1306   1306   
        ));
 1307   1307   
        runtime_components.push_interceptor(crate::config::endpoint::EndpointOverrideFeatureTrackerInterceptor);
        1308  +
        runtime_components.push_interceptor(crate::observability_feature::ObservabilityFeatureTrackerInterceptor);
 1308   1309   
        Self { config, runtime_components }
 1309   1310   
    }
 1310   1311   
}
 1311   1312   
 1312   1313   
impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ServiceRuntimePlugin {
 1313   1314   
    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
 1314   1315   
        self.config.clone()
 1315   1316   
    }
 1316   1317   
 1317   1318   
    fn order(&self) -> ::aws_smithy_runtime_api::client::runtime_plugin::Order {

tmp-codegen-diff/aws-sdk/sdk/transcribestreaming/src/lib.rs

@@ -168,168 +211,213 @@
  188    188   
/// Primitives such as `Blob` or `DateTime` used by other types.
  189    189   
pub mod primitives;
  190    190   
  191    191   
/// Data structures used by operation inputs/outputs.
  192    192   
pub mod types;
  193    193   
  194    194   
mod event_receiver;
  195    195   
  196    196   
mod event_stream_serde;
  197    197   
         198  +
mod observability_feature;
         199  +
  198    200   
pub(crate) mod protocol_serde;
  199    201   
  200    202   
mod sdk_feature_tracker;
  201    203   
  202    204   
mod serialization_settings;
  203    205   
  204    206   
mod endpoint_lib;
  205    207   
  206    208   
mod json_errors;
  207    209   

tmp-codegen-diff/aws-sdk/sdk/transcribestreaming/src/observability_feature.rs

@@ -0,1 +0,38 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/*
           3  +
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
           4  +
 * SPDX-License-Identifier: Apache-2.0
           5  +
 */
           6  +
           7  +
use aws_smithy_runtime::client::sdk_feature::SmithySdkFeature;
           8  +
use aws_smithy_runtime_api::{
           9  +
    box_error::BoxError,
          10  +
    client::interceptors::{context::BeforeSerializationInterceptorContextRef, Intercept},
          11  +
};
          12  +
use aws_smithy_types::config_bag::ConfigBag;
          13  +
          14  +
// Interceptor that tracks Smithy SDK features for observability (tracing/metrics).
          15  +
#[derive(Debug, Default)]
          16  +
pub(crate) struct ObservabilityFeatureTrackerInterceptor;
          17  +
          18  +
impl Intercept for ObservabilityFeatureTrackerInterceptor {
          19  +
    fn name(&self) -> &'static str {
          20  +
        "ObservabilityFeatureTrackerInterceptor"
          21  +
    }
          22  +
          23  +
    fn read_before_execution(&self, _context: &BeforeSerializationInterceptorContextRef<'_>, cfg: &mut ConfigBag) -> Result<(), BoxError> {
          24  +
        // Check if an OpenTelemetry meter provider is configured via the global provider
          25  +
        if let Ok(telemetry_provider) = aws_smithy_observability::global::get_telemetry_provider() {
          26  +
            let meter_provider = telemetry_provider.meter_provider();
          27  +
          28  +
            // Use provider_name() to detect OpenTelemetry without importing the otel crate.
          29  +
            // This avoids adding aws-smithy-observability-otel as a dependency.
          30  +
            // Note: as_any() is available for type-based checking if stronger guarantees are needed.
          31  +
            if meter_provider.provider_name() == "otel" {
          32  +
                cfg.interceptor_state().store_append(SmithySdkFeature::ObservabilityOtelMetrics);
          33  +
            }
          34  +
        }
          35  +
          36  +
        Ok(())
          37  +
    }
          38  +
}

tmp-codegen-diff/aws-sdk/tests/telemetry/Cargo.toml

@@ -5,5 +60,60 @@
   25     25   
features = ["test-util", "behavior-version-latest"]
   26     26   
version = "0.0.0-local"
   27     27   
   28     28   
[dev-dependencies.aws-sdk-s3]
   29     29   
path = "../../sdk/s3"
   30     30   
features = ["test-util", "behavior-version-latest"]
   31     31   
version = "0.0.0-local"
   32     32   
   33     33   
[dev-dependencies.aws-smithy-observability]
   34     34   
path = "../../sdk/aws-smithy-observability"
   35         -
version = "0.1.5"
          35  +
version = "0.1.6"
   36     36   
   37     37   
[dev-dependencies.aws-smithy-observability-otel]
   38     38   
path = "../../sdk/aws-smithy-observability-otel"
   39     39   
version = "0.1.3"
   40     40   
   41     41   
[dev-dependencies.aws-smithy-runtime]
   42     42   
path = "../../sdk/aws-smithy-runtime"
   43     43   
features = ["client", "test-util"]
   44     44   
version = "1.9.5"
   45     45   

tmp-codegen-diff/aws-sdk/tests/telemetry/tests/observability_feature_metrics.rs

@@ -0,1 +0,109 @@
           1  +
/*
           2  +
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
           3  +
 * SPDX-License-Identifier: Apache-2.0
           4  +
 */
           5  +
           6  +
use aws_config::Region;
           7  +
use aws_sdk_s3::config::{Credentials, SharedCredentialsProvider};
           8  +
use aws_smithy_observability::TelemetryProvider;
           9  +
use aws_smithy_runtime::client::http::test_util::{ReplayEvent, StaticReplayClient};
          10  +
use aws_smithy_types::body::SdkBody;
          11  +
use serial_test::serial;
          12  +
use utils::init_metrics;
          13  +
          14  +
mod utils;
          15  +
          16  +
// Note: These tests are written with a multi-threaded runtime since OTel requires that to work
          17  +
// and they are all run serially since they touch global state
          18  +
          19  +
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
          20  +
#[serial]
          21  +
async fn observability_otel_metrics_feature_tracked_in_user_agent() {
          22  +
    let (meter_provider, _exporter) = init_metrics();
          23  +
          24  +
    // Create a replay client to capture the actual HTTP request
          25  +
    let http_client = StaticReplayClient::new(vec![ReplayEvent::new(
          26  +
        http::Request::builder().body(SdkBody::empty()).unwrap(),
          27  +
        http::Response::builder().body(SdkBody::empty()).unwrap(),
          28  +
    )]);
          29  +
          30  +
    let config = aws_config::SdkConfig::builder()
          31  +
        .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests()))
          32  +
        .region(Region::new("us-east-1"))
          33  +
        .http_client(http_client.clone())
          34  +
        .build();
          35  +
          36  +
    let s3_client = aws_sdk_s3::Client::new(&config);
          37  +
    let _ = s3_client
          38  +
        .get_object()
          39  +
        .bucket("test-bucket")
          40  +
        .key("test.txt")
          41  +
        .send()
          42  +
        .await;
          43  +
          44  +
    // Get the actual HTTP request that was made
          45  +
    let requests = http_client.actual_requests();
          46  +
    let last_request = requests.last().expect("should have made a request");
          47  +
          48  +
    let user_agent = last_request
          49  +
        .headers()
          50  +
        .get("x-amz-user-agent")
          51  +
        .expect("should have user-agent header");
          52  +
          53  +
    // Should contain OBSERVABILITY_OTEL_METRICS metric (value "7")
          54  +
    // The metric appears in the m/ section, e.g. "m/E,b,7"
          55  +
    assert!(
          56  +
        user_agent.contains(",7") || user_agent.ends_with("/7") || user_agent.contains("7,"),
          57  +
        "User-Agent should contain observability OTel metrics feature (7), got: {}",
          58  +
        user_agent
          59  +
    );
          60  +
          61  +
    meter_provider.flush().unwrap();
          62  +
          63  +
    // Reset to noop for other tests
          64  +
    aws_smithy_observability::global::set_telemetry_provider(TelemetryProvider::noop()).unwrap();
          65  +
}
          66  +
          67  +
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
          68  +
#[serial]
          69  +
async fn noop_provider_does_not_track_observability_metrics() {
          70  +
    // Reset to noop provider
          71  +
    aws_smithy_observability::global::set_telemetry_provider(TelemetryProvider::noop()).unwrap();
          72  +
          73  +
    // Create a replay client to capture the actual HTTP request
          74  +
    let http_client = StaticReplayClient::new(vec![ReplayEvent::new(
          75  +
        http::Request::builder().body(SdkBody::empty()).unwrap(),
          76  +
        http::Response::builder().body(SdkBody::empty()).unwrap(),
          77  +
    )]);
          78  +
          79  +
    let config = aws_config::SdkConfig::builder()
          80  +
        .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests()))
          81  +
        .region(Region::new("us-east-1"))
          82  +
        .http_client(http_client.clone())
          83  +
        .build();
          84  +
          85  +
    let s3_client = aws_sdk_s3::Client::new(&config);
          86  +
    let _ = s3_client
          87  +
        .get_object()
          88  +
        .bucket("test-bucket")
          89  +
        .key("test.txt")
          90  +
        .send()
          91  +
        .await;
          92  +
          93  +
    // Get the actual HTTP request that was made
          94  +
    let requests = http_client.actual_requests();
          95  +
    let last_request = requests.last().expect("should have made a request");
          96  +
          97  +
    let user_agent = last_request
          98  +
        .headers()
          99  +
        .get("x-amz-user-agent")
         100  +
        .expect("should have user-agent header");
         101  +
         102  +
    // Should NOT contain OBSERVABILITY_OTEL_METRICS metric when using noop provider
         103  +
    // The metric value is "7"
         104  +
    assert!(
         105  +
        !user_agent.contains(",7") && !user_agent.ends_with("/7") && !user_agent.contains("7,"),
         106  +
        "User-Agent should not contain observability OTel metrics feature (7) with noop provider, got: {}",
         107  +
        user_agent
         108  +
    );
         109  +
}