Record TCP connection local socket address in metadata (#3286)
## Motivation and Context I want to use this field to uniquely identify TCP connection based on their `local_addr` + `remote_addr`. See https://github.com/awslabs/aws-sdk-rust/issues/990 for additional motivation for this change. ## Description - Add a new optional `local_addr` field in the `ConnectionMetadata` struct. - Transfer the `local_addr` `SocketAddress` from the `hyper::HttpInfo` to the `ConnectionMetadata` field. - Add to the `trace-serialize` example program so that it will print out the capture connection values. ## Testing `cargo test` in `rust-runtime/aws-smithy-runtime-api` and `aws-smithy-runtime`. Also ran: ``` thedeck@c889f3b04fb0 examples % cargo run --example trace-serialize Finished dev [unoptimized + debuginfo] target(s) in 0.13s Running `/Users/thedeck/repos/github/declanvk/smithy-rs/target/debug/examples/trace-serialize` 2023-12-06T00:13:15.605555Z INFO lazy_load_identity: aws_smithy_runtime::client::identity::cache::lazy: identity cache miss occurred; added new identity (took Ok(296µs)) 2023-12-06T00:13:15.608344Z INFO trace_serialize: Response received: response=Response { status: StatusCode(200), headers: Headers { headers: {"content-type": HeaderValue { _private: "application/json" }, "content-length": HeaderValue { _private: "17" }, "date": HeaderValue { _private: "Wed, 06 Dec 2023 00:13:15 GMT" }} }, body: SdkBody { inner: BoxBody, retryable: false }, extensions: Extensions } 2023-12-06T00:13:15.608388Z INFO trace_serialize: Captured connection info remote_addr=Some(127.0.0.1:13734) local_addr=Some(127.0.0.1:50199) 2023-12-06T00:13:15.608511Z INFO trace_serialize: Response received POKEMON_SERVICE_URL=http://localhost:13734 response=GetServerStatisticsOutput { calls_count: 0 } ``` You can see the log line with "Captured connection info" contains the `remote_addr` and the `local_addr` fields. ## Checklist - [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK 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._ Co-authored-by:Declan Kelly <thedeck@amazon.com>
Loading
Please register or sign in to comment