#aws-sdk #aws #x-ray #tracing #request-builder

xray-lite-aws-sdk

xray-lite extension for AWS SDK for Rust

1 unstable release

0.0.4 Mar 30, 2024

#789 in Debugging

Download history 13/week @ 2024-07-26 9/week @ 2024-08-02 1/week @ 2024-08-09 2/week @ 2024-08-23 27/week @ 2024-08-30 3/week @ 2024-09-06 6/week @ 2024-09-13 8/week @ 2024-09-20 14/week @ 2024-09-27 29/week @ 2024-10-04 1/week @ 2024-10-11

52 downloads per month

MIT license

82KB
1.5K SLoC

xray-lite-aws-sdk

xray-lite-aws-sdk is an extension of xray-lite for AWS SDK for Rust.

Installing xray-lite-aws-sdk

Add the following to your Cargo.toml file:

[dependencies]
xray-lite-aws-sdk = "0.0.4"

Usage

With this crate, you can easily add the X-Ray tracing capability to your AWS service requests through AWS SDK for Rust. It utilizes the interceptor which can be attached to CustomizableOperation available via the customize method of any request builder; e.g., aws_sdk_s3::operation::get_object::builders::GetObjectFluentBuilder::customize

The following example shows how to report a subsegment for each attempt of the S3 GetObject operation:

use aws_config::BehaviorVersion;
use xray_lite::{DaemonClient, SubsegmentContext};
use xray_lite_aws_sdk::ContextExt as _;

async fn get_object_from_s3() {
    let xray_client = DaemonClient::from_lambda_env().unwrap();
    let xray_context = SubsegmentContext::from_lambda_env(xray_client).unwrap();

    let config = aws_config::load_defaults(BehaviorVersion::latest()).await;
    let s3_client = aws_sdk_s3::Client::new(&config);
    s3_client
        .get_object()
        .bucket("the-bucket-name")
        .key("the-object-key")
        .customize()
        .interceptor(xray_context.intercept_operation("S3", "GetObject"))
        .send()
        .await
        .unwrap();
}

API Documentation

https://codemonger-io.github.io/xray-lite/api/xray_lite_aws_sdk/

Dependencies

~6–13MB
~158K SLoC