Skip to content

Commit

Permalink
remove checksum metric tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Velfi committed Dec 17, 2024
1 parent 27c5401 commit 324f9dc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 297 deletions.
16 changes: 0 additions & 16 deletions aws/rust-runtime/aws-inlineable/src/http_request_checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,6 @@ where
cfg: &mut ConfigBag,
) -> Result<(), BoxError> {
let checksum_algorithm = (self.algorithm_provider)(context.input())?;
if let Some(checksum_algorithm) = checksum_algorithm {
let feature = match checksum_algorithm {
ChecksumAlgorithm::Crc32 => Some(SmithySdkFeature::FlexibleChecksumsReqCrc32),
ChecksumAlgorithm::Crc32c => Some(SmithySdkFeature::FlexibleChecksumsReqCrc32c),
// TODO(flexible checksums v2) add CRC64 to this list
ChecksumAlgorithm::Sha1 => Some(SmithySdkFeature::FlexibleChecksumsReqSha1),
ChecksumAlgorithm::Sha256 => Some(SmithySdkFeature::FlexibleChecksumsReqSha256),
_ => {
tracing::warn!("can't insert business metric for unknown checksum algorithm.");
None
}
};
if let Some(feature) = feature {
cfg.interceptor_state().store_append(feature);
}
}

let mut layer = Layer::new("RequestChecksumInterceptor");
layer.store_put(RequestChecksumInterceptorState { checksum_algorithm });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,285 +328,4 @@ class UserAgentDecoratorTest {
}
}
}

@Test
fun `it emits business metric for checksum usage`() {
val model =
"""
namespace test
use aws.api#service
use aws.auth#sigv4
use aws.protocols#httpChecksum
use aws.protocols#restJson1
use smithy.rules#endpointRuleSet
@service(sdkId: "dontcare")
@restJson1
@sigv4(name: "dontcare")
@auth([sigv4])
@endpointRuleSet({
"version": "1.0",
"rules": [{ "type": "endpoint", "conditions": [], "endpoint": { "url": "https://example.com" } }],
"parameters": {
"Region": { "required": false, "type": "String", "builtIn": "AWS::Region" },
}
})
service TestService {
version: "2023-01-01",
operations: [HttpChecksumOperation, HttpChecksumStreamingOperation]
}
@http(uri: "/HttpChecksumOperation", method: "POST")
@optionalAuth
@httpChecksum(
requestChecksumRequired: true,
requestAlgorithmMember: "checksumAlgorithm",
requestValidationModeMember: "validationMode",
responseAlgorithms: ["CRC32", "CRC32C", "CRC64NVME", "SHA1", "SHA256"]
)
operation HttpChecksumOperation {
input: SomeInput,
output: SomeOutput
}
@input
structure SomeInput {
@httpHeader("x-amz-request-algorithm")
checksumAlgorithm: ChecksumAlgorithm
@httpHeader("x-amz-response-validation-mode")
validationMode: ValidationMode
@httpHeader("x-amz-checksum-crc32")
ChecksumCRC32: String
@httpHeader("x-amz-checksum-crc32c")
ChecksumCRC32C: String
@httpHeader("x-amz-checksum-crc64nvme")
ChecksumCRC64Nvme: String
@httpHeader("x-amz-checksum-sha1")
ChecksumSHA1: String
@httpHeader("x-amz-checksum-sha256")
ChecksumSHA256: String
@httpPayload
@required
body: Blob
}
@output
structure SomeOutput {}
@http(uri: "/HttpChecksumStreamingOperation", method: "POST")
@optionalAuth
@httpChecksum(
requestChecksumRequired: true,
requestAlgorithmMember: "checksumAlgorithm",
requestValidationModeMember: "validationMode",
responseAlgorithms: ["CRC32", "CRC32C", "CRC64NVME", "SHA1", "SHA256"]
)
operation HttpChecksumStreamingOperation {
input: SomeStreamingInput,
output: SomeStreamingOutput
}
@streaming
blob StreamingBlob
@input
structure SomeStreamingInput {
@httpHeader("x-amz-request-algorithm")
checksumAlgorithm: ChecksumAlgorithm
@httpHeader("x-amz-response-validation-mode")
validationMode: ValidationMode
@httpPayload
@required
body: StreamingBlob
}
@output
structure SomeStreamingOutput {}
enum ChecksumAlgorithm {
CRC32
CRC32C
CRC64NVME
SHA1
SHA256
}
enum ValidationMode {
ENABLED
}
""".asSmithyModel(smithyVersion = "2.0")

awsSdkIntegrationTest(model) { ctx, rustCrate ->
rustCrate.integrationTest("business_metrics_for_checksums") {
val moduleName = ctx.moduleUseName()
val rc = ctx.runtimeConfig
rust(
"""
use $moduleName::config::Region;
use $moduleName::types::ChecksumAlgorithm;
use $moduleName::primitives::Blob;
use $moduleName::{Client, Config};
""",
)

tokioTest("should_emit_metric_in_user_agent_for_crc32") {
rustTemplate(
"""
let (http_client, rcvr) = #{capture_request}(#{None});
let config = Config::builder()
.region(Region::new("us-east-1"))
.http_client(http_client.clone())
.with_test_defaults()
.build();
let client = Client::from_conf(config);
let _ = client
.http_checksum_operation()
.checksum_algorithm(ChecksumAlgorithm::Crc32)
.body(Blob::new(b"Hello, world!"))
.send()
.await;
let expected_req = rcvr.expect_request();
let user_agent = expected_req
.headers()
.get("x-amz-user-agent")
.unwrap();
#{assert_ua_contains_metric_values}(user_agent, &["U"]);
""",
*preludeScope,
"assert_ua_contains_metric_values" to
AwsRuntimeType.awsRuntimeTestUtil(rc)
.resolve("user_agent::test_util::assert_ua_contains_metric_values"),
"capture_request" to RuntimeType.captureRequest(rc),
"disable_interceptor" to
RuntimeType.smithyRuntimeApiClient(rc)
.resolve("client::interceptors::disable_interceptor"),
"UserAgentInterceptor" to
AwsRuntimeType.awsRuntime(rc)
.resolve("user_agent::UserAgentInterceptor"),
)
}

tokioTest("should_emit_metric_in_user_agent_for_crc32c") {
rustTemplate(
"""
let (http_client, rcvr) = #{capture_request}(#{None});
let config = Config::builder()
.region(Region::new("us-east-1"))
.http_client(http_client.clone())
.with_test_defaults()
.build();
let client = Client::from_conf(config);
let _ = client
.http_checksum_operation()
.checksum_algorithm(ChecksumAlgorithm::Crc32C)
.body(Blob::new(b"Hello, world!"))
.send()
.await;
let expected_req = rcvr.expect_request();
let user_agent = expected_req
.headers()
.get("x-amz-user-agent")
.unwrap();
#{assert_ua_contains_metric_values}(user_agent, &["V"]);
""",
*preludeScope,
"assert_ua_contains_metric_values" to
AwsRuntimeType.awsRuntimeTestUtil(rc)
.resolve("user_agent::test_util::assert_ua_contains_metric_values"),
"capture_request" to RuntimeType.captureRequest(rc),
"disable_interceptor" to
RuntimeType.smithyRuntimeApiClient(rc)
.resolve("client::interceptors::disable_interceptor"),
"UserAgentInterceptor" to
AwsRuntimeType.awsRuntime(rc)
.resolve("user_agent::UserAgentInterceptor"),
)
}

tokioTest("should_emit_metric_in_user_agent_for_sha1") {
rustTemplate(
"""
let (http_client, rcvr) = #{capture_request}(#{None});
let config = Config::builder()
.region(Region::new("us-east-1"))
.http_client(http_client.clone())
.with_test_defaults()
.build();
let client = Client::from_conf(config);
let _ = client
.http_checksum_operation()
.checksum_algorithm(ChecksumAlgorithm::Sha1)
.body(Blob::new(b"Hello, world!"))
.send()
.await;
let expected_req = rcvr.expect_request();
let user_agent = expected_req
.headers()
.get("x-amz-user-agent")
.unwrap();
#{assert_ua_contains_metric_values}(user_agent, &["X"]);
""",
*preludeScope,
"assert_ua_contains_metric_values" to
AwsRuntimeType.awsRuntimeTestUtil(rc)
.resolve("user_agent::test_util::assert_ua_contains_metric_values"),
"capture_request" to RuntimeType.captureRequest(rc),
"disable_interceptor" to
RuntimeType.smithyRuntimeApiClient(rc)
.resolve("client::interceptors::disable_interceptor"),
"UserAgentInterceptor" to
AwsRuntimeType.awsRuntime(rc)
.resolve("user_agent::UserAgentInterceptor"),
)
}

tokioTest("should_emit_metric_in_user_agent_for_sha256") {
rustTemplate(
"""
let (http_client, rcvr) = #{capture_request}(#{None});
let config = Config::builder()
.region(Region::new("us-east-1"))
.http_client(http_client.clone())
.with_test_defaults()
.build();
let client = Client::from_conf(config);
let _ = client
.http_checksum_operation()
.checksum_algorithm(ChecksumAlgorithm::Sha256)
.body(Blob::new(b"Hello, world!"))
.send()
.await;
let expected_req = rcvr.expect_request();
let user_agent = expected_req
.headers()
.get("x-amz-user-agent")
.unwrap();
#{assert_ua_contains_metric_values}(user_agent, &["Y"]);
""",
*preludeScope,
"assert_ua_contains_metric_values" to
AwsRuntimeType.awsRuntimeTestUtil(rc)
.resolve("user_agent::test_util::assert_ua_contains_metric_values"),
"capture_request" to RuntimeType.captureRequest(rc),
"disable_interceptor" to
RuntimeType.smithyRuntimeApiClient(rc)
.resolve("client::interceptors::disable_interceptor"),
"UserAgentInterceptor" to
AwsRuntimeType.awsRuntime(rc)
.resolve("user_agent::UserAgentInterceptor"),
)
}
}
}
}
}

0 comments on commit 324f9dc

Please sign in to comment.