Unverified Commit 3cdf49e6 authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Improve client tracing spans (#2044)

* Emit spans for implementers of map request middleware traits
* Instrument dispatch with its own span
* Fix trace span hierarchy
* Partially flatten the middleware span hierarchy
* Make `MapRequest::name` required
* Add sub-spans to the `load_response` span
parent 577c90b7
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -677,3 +677,15 @@ The Unit type for a Union member is no longer rendered. The serializers and pars
references = ["smithy-rs#1989"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "all" }
author = "ysaito1001"

[[aws-sdk-rust]]
message = "Fixed and improved the request `tracing` span hierarchy to improve log messages, profiling, and debuggability."
references = ["smithy-rs#2044", "smithy-rs#371"]
meta = { "breaking" = false, "tada" = true, "bug" = false }
author = "jdisanti"

[[smithy-rs]]
message = "Fixed and improved the request `tracing` span hierarchy to improve log messages, profiling, and debuggability."
references = ["smithy-rs#2044", "smithy-rs#371"]
meta = { "breaking" = false, "tada" = true, "bug" = false, "target" = "client"}
author = "jdisanti"
+4 −0
Original line number Diff line number Diff line
@@ -160,6 +160,10 @@ impl AsyncMapRequest for TokenMiddleware {
    type Error = ImdsError;
    type Future = Pin<Box<dyn Future<Output = Result<Request, Self::Error>> + Send + 'static>>;

    fn name(&self) -> &'static str {
        "attach_imds_token"
    }

    fn apply(&self, request: Request) -> Self::Future {
        let this = self.clone();
        Box::pin(async move { this.add_token(request).await })
+1 −1
Original line number Diff line number Diff line
@@ -84,10 +84,10 @@ impl ProvideCredentials for LazyCachingCredentialsProvider {
                // There may be other threads also loading simultaneously, but this is OK
                // since the futures are not eagerly executed, and the cache will only run one
                // of them.
                let span = trace_span!("lazy_load_credentials");
                let future = Timeout::new(loader.provide_credentials(), timeout_future);
                cache
                    .get_or_load(|| {
                        let span = trace_span!("lazy_load_credentials");
                        async move {
                            let credentials = future.await.map_err(|_err| {
                                CredentialsError::provider_timed_out(load_timeout)
+4 −0
Original line number Diff line number Diff line
@@ -133,6 +133,10 @@ impl From<AwsAuthStageErrorKind> for AwsAuthStageError {
impl MapRequest for AwsAuthStage {
    type Error = AwsAuthStageError;

    fn name(&self) -> &'static str {
        "resolve_endpoint"
    }

    fn apply(&self, request: Request) -> Result<Request, Self::Error> {
        request.augment(|http_req, props| {
            let endpoint = props
+4 −0
Original line number Diff line number Diff line
@@ -101,6 +101,10 @@ impl AsyncMapRequest for CredentialsStage {
    type Error = CredentialsStageError;
    type Future = Pin<Box<dyn Future<Output = Result<Request, Self::Error>> + Send + 'static>>;

    fn name(&self) -> &'static str {
        "retrieve_credentials"
    }

    fn apply(&self, request: Request) -> BoxFuture<Result<Request, Self::Error>> {
        Box::pin(Self::load_creds(request))
    }
Loading