Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Library Instrumentation for AWS SDK for Java version 1.11 and higher

Provides OpenTelemetry instrumentation for the AWS SDK for Java.

Quickstart

Add these dependencies to your project

Replace OPENTELEMETRY_VERSION with the latest release.

For Maven, add to your pom.xml dependencies:

<dependencies>
  <dependency>
    <groupId>io.opentelemetry.instrumentation</groupId>
    <artifactId>opentelemetry-aws-sdk-1.11</artifactId>
    <version>OPENTELEMETRY_VERSION</version>
  </dependency>
</dependencies>

For Gradle, add to your dependencies:

implementation("io.opentelemetry.instrumentation:opentelemetry-aws-sdk-1.11:OPENTELEMETRY_VERSION")

Usage

The instrumentation library provides a RequestHandler2 that can be added to any AWS SDK v1 client builder to provide spans and context propagation.

import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.awssdk.v1_11.AwsSdkTelemetry;

public class AwsSdkConfiguration {

  // Use this to create instrumented AWS SDK clients.
  public AmazonS3 createS3Client(OpenTelemetry openTelemetry) {
    return AmazonS3ClientBuilder.standard()
        .withRequestHandlers(
            AwsSdkTelemetry.builder(openTelemetry)
                .build()
                .createRequestHandler())
        .build();
  }

  // This pattern works for all AWS SDK v1 client builders (S3, SQS, DynamoDB, etc.).
}