https://github.com/appsflyer/aws-sdk-java-opentelemetry-metrics
OpenTelemetry Metric Publisher for AWS SDK for Java – Export AWS SDK metrics to OpenTelemetry for enhanced observability
https://github.com/appsflyer/aws-sdk-java-opentelemetry-metrics
Last synced: 2 months ago
JSON representation
OpenTelemetry Metric Publisher for AWS SDK for Java – Export AWS SDK metrics to OpenTelemetry for enhanced observability
- Host: GitHub
- URL: https://github.com/appsflyer/aws-sdk-java-opentelemetry-metrics
- Owner: AppsFlyer
- License: mit
- Created: 2024-09-15T11:24:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-11T07:35:41.000Z (about 1 year ago)
- Last Synced: 2025-10-28T21:28:11.505Z (6 months ago)
- Language: Java
- Size: 54.7 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# AWS SDK Java OpenTelemetry Metrics
A lightweight metrics publisher that integrates AWS SDK metrics with OpenTelemetry, allowing you to monitor and collect
AWS client performance metrics in your distributed applications.
## Usage
This library integrates AWS SDK Java metrics with OpenTelemetry’s metrics API, allowing you to collect and publish AWS client performance data such as API call durations, retry counts, and more.
### Basic Example
Here’s a simple example of how to use the `OtelMetricPublisher`:
```java
import com.appsflyer.otelawsmetrics.OtelMetricPublisher;
import io.opentelemetry.api.OpenTelemetry;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;
import software.amazon.awssdk.metrics.MetricPublisher;
public class MyAwsService {
private final DynamoDbAsyncClient dynamoDbAsyncClient;
public MyAwsService(OpenTelemetry openTelemetry) {
// Create the metric publisher
MetricPublisher metricPublisher = new OtelMetricPublisher(openTelemetry, "aws.sdk");
// Create the DynamoDbAsyncClient with the metric publisher
this.dynamoDbAsyncClient = DynamoDbAsyncClient.builder()
.overrideConfiguration(ClientOverrideConfiguration.builder()
.addMetricPublisher(metricPublisher)
.build())
.build();
}
public void putItemAsync(String tableName, Map item) {
// Perform DynamoDB operations and automatically collect metrics
dynamoDbAsyncClient.putItem(putItemRequest -> putItemRequest.tableName(tableName).item(item));
}
}
```
### Configuration
You can configure the OtelMetricPublisher with additional options if needed:
```java
Executor customExecutor = Executors.newSingleThreadExecutor();
OtelMetricPublisher metricPublisher = new OtelMetricPublisher(OpenTelemetry.get(), customExecutor);
```
This allows you to use a custom executor for asynchronous metrics publishing.
## License
This project is licensed under the MIT License - see the LICENSE file for details.