pub trait AwsBuilderInstrument<'a>where
Self: Sized,{
// Required method
fn build_aws_span(&self) -> AwsSpanBuilder<'a>;
// Provided method
fn instrument(self) -> InstrumentedFluentBuilder<'a, Self> { ... }
}Expand description
A trait for AWS service clients that can be instrumented with OpenTelemetry tracing.
This trait provides methods to build spans for AWS operations and instrument the fluent builders returned by AWS SDK operations. The instrumentation automatically extracts both input attributes (from the fluent builder configuration) and output attributes (from the operation response) following OpenTelemetry semantic conventions.
§Example
use aws_sdk_dynamodb::{Client as DynamoClient, types::AttributeValue};
use telemetry_rust::middleware::aws::AwsBuilderInstrument;
async fn query_table() -> Result<i32, Box<dyn std::error::Error>> {
let config = aws_config::load_from_env().await;
let dynamo_client = DynamoClient::new(&config);
let resp = dynamo_client
.query()
.table_name("table_name")
.index_name("my_index")
.key_condition_expression("PK = :pk")
.expression_attribute_values(":pk", AttributeValue::S("Test".to_string()))
.consistent_read(true)
.projection_expression("id,name")
.instrument()
.send()
.await?;
// Automatically extracts span attributes from the builder:
// - aws.dynamodb.table_name: "table_name"
// - aws.dynamodb.index_name: "my_index"
// - aws.dynamodb.consistent_read: true
// - aws.dynamodb.projection: "id,name"
//
// And from the AWS output:
// - aws.dynamodb.count: number of items returned
// - aws.dynamodb.scanned_count: number of items scanned
println!("DynamoDB items: {:#?}", resp.items());
Ok(resp.count())
}§Comparison with Manual Instrumentation
This trait provides automatic instrumentation as an alternative to manual instrumentation
using AwsInstrument. The automatic approach extracts attributes based on OpenTelemetry
semantic conventions without requiring explicit attribute specification:
// Automatic instrumentation (recommended)
let _ = dynamo_client
.get_item()
.table_name("table")
.instrument() // All attributes extracted automatically
.send()
.await?;
// Manual instrumentation (more control, more verbose)
let _ = dynamo_client
.get_item()
.table_name("table")
.send()
.instrument(DynamodbSpanBuilder::get_item("table"))
.await?;Required Methods§
Sourcefn build_aws_span(&self) -> AwsSpanBuilder<'a>
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Builds an AWS span for the specific operation represented by this builder.
Returns an AwsSpanBuilder that contains the necessary span attributes
and metadata for the AWS operation.
Provided Methods§
Sourcefn instrument(self) -> InstrumentedFluentBuilder<'a, Self>
fn instrument(self) -> InstrumentedFluentBuilder<'a, Self>
Instruments this fluent builder with OpenTelemetry tracing.
Returns an InstrumentedFluentBuilder that will automatically create
and manage spans when the operation is executed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<'a> AwsBuilderInstrument<'a> for BatchExecuteStatementFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for BatchExecuteStatementFluentBuilder
Source§fn build_aws_span(&self) -> AwsSpanBuilder<'a>
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Table names are not automatically extracted from PartiQL statement
Source§impl<'a> AwsBuilderInstrument<'a> for BatchGetItemFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for BatchGetItemFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for BatchWriteItemFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for BatchWriteItemFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for CreateBackupFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for CreateBackupFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for CreateGlobalTableFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for CreateGlobalTableFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for CreateTableFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for CreateTableFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DeleteBackupFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DeleteBackupFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DeleteItemFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DeleteItemFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DeleteResourcePolicyFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DeleteResourcePolicyFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DeleteTableFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DeleteTableFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DescribeBackupFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DescribeBackupFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DescribeContinuousBackupsFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DescribeContinuousBackupsFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DescribeContributorInsightsFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DescribeContributorInsightsFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DescribeEndpointsFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DescribeEndpointsFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DescribeExportFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DescribeExportFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DescribeGlobalTableFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DescribeGlobalTableFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DescribeGlobalTableSettingsFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DescribeGlobalTableSettingsFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DescribeImportFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DescribeImportFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DescribeKinesisStreamingDestinationFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DescribeKinesisStreamingDestinationFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DescribeLimitsFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DescribeLimitsFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DescribeTableFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DescribeTableFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DescribeTableReplicaAutoScalingFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DescribeTableReplicaAutoScalingFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DescribeTimeToLiveFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DescribeTimeToLiveFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for DisableKinesisStreamingDestinationFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for DisableKinesisStreamingDestinationFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for EnableKinesisStreamingDestinationFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for EnableKinesisStreamingDestinationFluentBuilder
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Source§impl<'a> AwsBuilderInstrument<'a> for ExecuteStatementFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for ExecuteStatementFluentBuilder
Source§fn build_aws_span(&self) -> AwsSpanBuilder<'a>
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Table name are not automatically extracted from PartiQL statement
Source§impl<'a> AwsBuilderInstrument<'a> for ExecuteTransactionFluentBuilder
impl<'a> AwsBuilderInstrument<'a> for ExecuteTransactionFluentBuilder
Source§fn build_aws_span(&self) -> AwsSpanBuilder<'a>
fn build_aws_span(&self) -> AwsSpanBuilder<'a>
Table names are not automatically extracted from PartiQL statement