Trait InstrumentedFluentBuilderOutput

Source
pub trait InstrumentedFluentBuilderOutput {
    // Provided method
    fn extract_attributes(&self) -> impl IntoIterator<Item = KeyValue> { ... }
}
Expand description

A trait for extracting OpenTelemetry attributes from AWS operation output objects.

This trait enables AWS SDK operation outputs to contribute additional telemetry data to spans after operations complete. It’s automatically used by AwsBuilderInstrument to extract meaningful span attributes like item counts, error rates, and other response metadata that enhances observability.

§Usage

Can be used together with AwsBuilderInstrument::build_aws_span when access to the underlying AwsSpan is required.

§Example

use aws_sdk_dynamodb::{Client as DynamoClient, types::ReturnConsumedCapacity};
use telemetry_rust::{
    KeyValue,
    middleware::aws::{AwsBuilderInstrument, InstrumentedFluentBuilderOutput},
    semconv,
};

async fn query_table() -> Result<usize, Box<dyn std::error::Error>> {
    let config = aws_config::load_from_env().await;
    let dynamo_client = DynamoClient::new(&config);

    let statement = "SELECT * FROM test";
    let query = dynamo_client
        .execute_statement()
        .statement(statement)
        .return_consumed_capacity(ReturnConsumedCapacity::Total);

    let mut span = query
        // Extract span from fluent builder
        .build_aws_span()
        // Set additional attributes
        .attribute(KeyValue::new(semconv::DB_QUERY_TEXT, statement))
        // Start the span
        .start();

    let result = query.send().await;
    if let Ok(output) = result.as_ref() {
        // Extract span attributes from ExecuteStatement output
        span.set_attributes(output.extract_attributes());
        // Set additional attributes
        span.set_attribute(KeyValue::new(
            semconv::AWS_DYNAMODB_CONSUMED_CAPACITY,
            format!("{:?}", output.consumed_capacity().unwrap()),
        ));
    }
    // End the span
    span.end(&result);

    let items = result?.items.unwrap_or_default();

    println!("DynamoDB items: {items:#?}");
    Ok(items.len())
}

§Implementation Notes

Implementations should extract relevant attributes following OpenTelemetry semantic conventions for the specific AWS service. The extracted attributes will be added to the span after the operation completes successfully.

Provided Methods§

Source

fn extract_attributes(&self) -> impl IntoIterator<Item = KeyValue>

Extracts OpenTelemetry attributes from the AWS operation output.

Return an iterator of KeyValue pairs representing span attributes.

The default implementation returns no attributes, which is appropriate for operations that don’t have meaningful response metrics to extract.

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 InstrumentedFluentBuilderOutput for BatchExecuteStatementOutput

Source§

impl InstrumentedFluentBuilderOutput for BatchGetItemOutput

Source§

impl InstrumentedFluentBuilderOutput for BatchWriteItemOutput

Source§

impl InstrumentedFluentBuilderOutput for CreateBackupOutput

Source§

impl InstrumentedFluentBuilderOutput for CreateGlobalTableOutput

Source§

impl InstrumentedFluentBuilderOutput for CreateTableOutput

Source§

impl InstrumentedFluentBuilderOutput for DeleteBackupOutput

Source§

impl InstrumentedFluentBuilderOutput for DeleteItemOutput

Source§

impl InstrumentedFluentBuilderOutput for DeleteResourcePolicyOutput

Source§

impl InstrumentedFluentBuilderOutput for DeleteTableOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeBackupOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeContinuousBackupsOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeContributorInsightsOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeEndpointsOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeExportOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeGlobalTableOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeGlobalTableSettingsOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeImportOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeKinesisStreamingDestinationOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeLimitsOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeTableOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeTableReplicaAutoScalingOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeTimeToLiveOutput

Source§

impl InstrumentedFluentBuilderOutput for DisableKinesisStreamingDestinationOutput

Source§

impl InstrumentedFluentBuilderOutput for EnableKinesisStreamingDestinationOutput

Source§

impl InstrumentedFluentBuilderOutput for ExecuteStatementOutput

Source§

impl InstrumentedFluentBuilderOutput for ExecuteTransactionOutput

Source§

impl InstrumentedFluentBuilderOutput for ExportTableToPointInTimeOutput

Source§

impl InstrumentedFluentBuilderOutput for GetItemOutput

Source§

impl InstrumentedFluentBuilderOutput for GetResourcePolicyOutput

Source§

impl InstrumentedFluentBuilderOutput for ImportTableOutput

Source§

impl InstrumentedFluentBuilderOutput for ListBackupsOutput

Source§

impl InstrumentedFluentBuilderOutput for ListContributorInsightsOutput

Source§

impl InstrumentedFluentBuilderOutput for ListExportsOutput

Source§

impl InstrumentedFluentBuilderOutput for ListGlobalTablesOutput

Source§

impl InstrumentedFluentBuilderOutput for ListImportsOutput

Source§

impl InstrumentedFluentBuilderOutput for ListTablesOutput

Source§

impl InstrumentedFluentBuilderOutput for ListTagsOfResourceOutput

Source§

impl InstrumentedFluentBuilderOutput for PutItemOutput

Source§

impl InstrumentedFluentBuilderOutput for PutResourcePolicyOutput

Source§

impl InstrumentedFluentBuilderOutput for QueryOutput

Source§

impl InstrumentedFluentBuilderOutput for RestoreTableFromBackupOutput

Source§

impl InstrumentedFluentBuilderOutput for RestoreTableToPointInTimeOutput

Source§

impl InstrumentedFluentBuilderOutput for ScanOutput

Source§

impl InstrumentedFluentBuilderOutput for TagResourceOutput

Source§

impl InstrumentedFluentBuilderOutput for TransactGetItemsOutput

Source§

impl InstrumentedFluentBuilderOutput for TransactWriteItemsOutput

Source§

impl InstrumentedFluentBuilderOutput for UntagResourceOutput

Source§

impl InstrumentedFluentBuilderOutput for UpdateContinuousBackupsOutput

Source§

impl InstrumentedFluentBuilderOutput for UpdateContributorInsightsOutput

Source§

impl InstrumentedFluentBuilderOutput for UpdateGlobalTableOutput

Source§

impl InstrumentedFluentBuilderOutput for UpdateGlobalTableSettingsOutput

Source§

impl InstrumentedFluentBuilderOutput for UpdateItemOutput

Source§

impl InstrumentedFluentBuilderOutput for UpdateKinesisStreamingDestinationOutput

Source§

impl InstrumentedFluentBuilderOutput for UpdateTableOutput

Source§

impl InstrumentedFluentBuilderOutput for UpdateTableReplicaAutoScalingOutput

Source§

impl InstrumentedFluentBuilderOutput for UpdateTimeToLiveOutput

Source§

impl InstrumentedFluentBuilderOutput for CreateDeliveryStreamOutput

Source§

impl InstrumentedFluentBuilderOutput for DeleteDeliveryStreamOutput

Source§

impl InstrumentedFluentBuilderOutput for DescribeDeliveryStreamOutput

Source§

impl InstrumentedFluentBuilderOutput for ListDeliveryStreamsOutput

Source§

impl InstrumentedFluentBuilderOutput for ListTagsForDeliveryStreamOutput

Source§

impl InstrumentedFluentBuilderOutput for PutRecordOutput

Source§

impl InstrumentedFluentBuilderOutput for PutRecordBatchOutput

Source§

impl InstrumentedFluentBuilderOutput for StartDeliveryStreamEncryptionOutput

Source§

impl InstrumentedFluentBuilderOutput for StopDeliveryStreamEncryptionOutput

Source§

impl InstrumentedFluentBuilderOutput for TagDeliveryStreamOutput

Source§

impl InstrumentedFluentBuilderOutput for UntagDeliveryStreamOutput

Source§

impl InstrumentedFluentBuilderOutput for UpdateDestinationOutput

Source§

impl InstrumentedFluentBuilderOutput for AddPermissionOutput

Source§

impl InstrumentedFluentBuilderOutput for CheckIfPhoneNumberIsOptedOutOutput

Source§

impl InstrumentedFluentBuilderOutput for ConfirmSubscriptionOutput

Source§

impl InstrumentedFluentBuilderOutput for CreatePlatformApplicationOutput

Source§

impl InstrumentedFluentBuilderOutput for CreatePlatformEndpointOutput

Source§

impl InstrumentedFluentBuilderOutput for CreateSmsSandboxPhoneNumberOutput

Source§

impl InstrumentedFluentBuilderOutput for CreateTopicOutput

Source§

impl InstrumentedFluentBuilderOutput for DeleteEndpointOutput

Source§

impl InstrumentedFluentBuilderOutput for DeletePlatformApplicationOutput

Source§

impl InstrumentedFluentBuilderOutput for DeleteSmsSandboxPhoneNumberOutput

Source§

impl InstrumentedFluentBuilderOutput for DeleteTopicOutput

Source§

impl InstrumentedFluentBuilderOutput for GetDataProtectionPolicyOutput

Source§

impl InstrumentedFluentBuilderOutput for GetEndpointAttributesOutput

Source§

impl InstrumentedFluentBuilderOutput for GetPlatformApplicationAttributesOutput

Source§

impl InstrumentedFluentBuilderOutput for GetSmsAttributesOutput

Source§

impl InstrumentedFluentBuilderOutput for GetSmsSandboxAccountStatusOutput

Source§

impl InstrumentedFluentBuilderOutput for GetSubscriptionAttributesOutput

Source§

impl InstrumentedFluentBuilderOutput for GetTopicAttributesOutput

Source§

impl InstrumentedFluentBuilderOutput for ListEndpointsByPlatformApplicationOutput

Source§

impl InstrumentedFluentBuilderOutput for ListOriginationNumbersOutput

Source§

impl InstrumentedFluentBuilderOutput for ListPhoneNumbersOptedOutOutput

Source§

impl InstrumentedFluentBuilderOutput for ListPlatformApplicationsOutput

Source§

impl InstrumentedFluentBuilderOutput for ListSmsSandboxPhoneNumbersOutput

Source§

impl InstrumentedFluentBuilderOutput for ListSubscriptionsOutput

Source§

impl InstrumentedFluentBuilderOutput for ListSubscriptionsByTopicOutput

Source§

impl InstrumentedFluentBuilderOutput for ListTagsForResourceOutput

Source§

impl InstrumentedFluentBuilderOutput for ListTopicsOutput

Source§

impl InstrumentedFluentBuilderOutput for OptInPhoneNumberOutput

Source§

impl InstrumentedFluentBuilderOutput for PublishOutput

Source§

impl InstrumentedFluentBuilderOutput for PublishBatchOutput

Source§

impl InstrumentedFluentBuilderOutput for PutDataProtectionPolicyOutput

Source§

impl InstrumentedFluentBuilderOutput for RemovePermissionOutput

Source§

impl InstrumentedFluentBuilderOutput for SetEndpointAttributesOutput

Source§

impl InstrumentedFluentBuilderOutput for SetPlatformApplicationAttributesOutput

Source§

impl InstrumentedFluentBuilderOutput for SetSmsAttributesOutput

Source§

impl InstrumentedFluentBuilderOutput for SetSubscriptionAttributesOutput

Source§

impl InstrumentedFluentBuilderOutput for SetTopicAttributesOutput

Source§

impl InstrumentedFluentBuilderOutput for SubscribeOutput

Source§

impl InstrumentedFluentBuilderOutput for TagResourceOutput

Source§

impl InstrumentedFluentBuilderOutput for UnsubscribeOutput

Source§

impl InstrumentedFluentBuilderOutput for UntagResourceOutput

Source§

impl InstrumentedFluentBuilderOutput for VerifySmsSandboxPhoneNumberOutput

Source§

impl InstrumentedFluentBuilderOutput for AddPermissionOutput

Source§

impl InstrumentedFluentBuilderOutput for CancelMessageMoveTaskOutput

Source§

impl InstrumentedFluentBuilderOutput for ChangeMessageVisibilityOutput

Source§

impl InstrumentedFluentBuilderOutput for ChangeMessageVisibilityBatchOutput

Source§

impl InstrumentedFluentBuilderOutput for CreateQueueOutput

Source§

impl InstrumentedFluentBuilderOutput for DeleteMessageOutput

Source§

impl InstrumentedFluentBuilderOutput for DeleteMessageBatchOutput

Source§

impl InstrumentedFluentBuilderOutput for DeleteQueueOutput

Source§

impl InstrumentedFluentBuilderOutput for GetQueueAttributesOutput

Source§

impl InstrumentedFluentBuilderOutput for GetQueueUrlOutput

Source§

impl InstrumentedFluentBuilderOutput for ListDeadLetterSourceQueuesOutput

Source§

impl InstrumentedFluentBuilderOutput for ListMessageMoveTasksOutput

Source§

impl InstrumentedFluentBuilderOutput for ListQueueTagsOutput

Source§

impl InstrumentedFluentBuilderOutput for ListQueuesOutput

Source§

impl InstrumentedFluentBuilderOutput for PurgeQueueOutput

Source§

impl InstrumentedFluentBuilderOutput for ReceiveMessageOutput

Source§

impl InstrumentedFluentBuilderOutput for RemovePermissionOutput

Source§

impl InstrumentedFluentBuilderOutput for SendMessageOutput

Source§

impl InstrumentedFluentBuilderOutput for SendMessageBatchOutput

Source§

impl InstrumentedFluentBuilderOutput for SetQueueAttributesOutput

Source§

impl InstrumentedFluentBuilderOutput for StartMessageMoveTaskOutput

Source§

impl InstrumentedFluentBuilderOutput for TagQueueOutput

Source§

impl InstrumentedFluentBuilderOutput for UntagQueueOutput

Implementors§