Unverified Commit bbe1f0a9 authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Add tracing events to parse_response (#228)

* Add tracing events to parse_response

* Fix test
parent fa59140c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ where
    pub async fn call<O, T, E, Retry>(&self, input: Operation<O, Retry>) -> Result<T, SdkError<E>>
    where
        O: ParseHttpResponse<hyper::Body, Output = Result<T, E>> + Send + 'static,
        E: Error,
    {
        self.call_raw(input).await.map(|res| res.parsed)
    }
@@ -87,6 +88,7 @@ where
    ) -> Result<SdkSuccess<R>, SdkError<E>>
    where
        O: ParseHttpResponse<hyper::Body, Output = Result<R, E>> + Send + 'static,
        E: Error,
    {
        let signer = MapRequestLayer::for_mapper(SigV4SigningStage::new(SigV4Signer::new()));
        let endpoint_resolver = MapRequestLayer::for_mapper(AwsEndpointStage);
+14 −1
Original line number Diff line number Diff line
@@ -20,15 +20,28 @@ use smithy_http::response::ParseHttpResponse;
use std::convert::Infallible;
use std::sync::Arc;
use std::time::{Duration, UNIX_EPOCH};
use std::error::Error;
use std::fmt::{Display, Formatter};
use std::fmt;

#[derive(Clone)]
struct TestOperationParser;

#[derive(Debug)]
struct OperationError;
impl Display for OperationError {
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        write!(f, "{:?}", self)
    }
}

impl Error for OperationError {}

impl<B> ParseHttpResponse<B> for TestOperationParser
where
    B: http_body::Body,
{
    type Output = Result<String, String>;
    type Output = Result<String, OperationError>;

    fn parse_unloaded(&self, _response: &mut Response<B>) -> Option<Self::Output> {
        Some(Ok("Hello!".to_string()))
+2 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ task("relocateServices") {
            }
        }
    }
    outputs.upToDateWhen { false }
}

task("relocateExamples") {
@@ -151,6 +152,7 @@ tasks.register<Copy>("relocateRuntime") {
        exclude("**/Cargo.lock")
    }
    into(sdkOutputDir)
    outputs.upToDateWhen { false }
}

fun generateCargoWorkspace(services: List<AwsService>): String {
+1 −0
Original line number Diff line number Diff line
@@ -11,3 +11,4 @@ aws-hyper = { path = "../../build/aws-sdk/aws-hyper" }
tokio = { version = "1", features = ["full"]}
# optional
env_logger = "0.8.2"
tracing-subscriber = { version = "0.2.16", features = ["fmt"] }
+3 −2
Original line number Diff line number Diff line
use kms::operation::GenerateRandom;
use kms::Region;
use env_logger::Env;
use tracing_subscriber::fmt::SubscriberBuilder;
use tracing_subscriber::fmt::format::FmtSpan;

#[tokio::main]
async fn main() {
    env_logger::init_from_env(Env::default().default_filter_or("info"));
    SubscriberBuilder::default().with_env_filter("info").with_span_events(FmtSpan::CLOSE).init();
    let config = kms::Config::builder()
        // region can also be loaded from AWS_DEFAULT_REGION, just remove this line.
        .region(Region::from("us-east-1"))
Loading