From 0533c26f5e2971478cc013c71b57d22c9454790e Mon Sep 17 00:00:00 2001 From: Yevgeni Tsodikov Date: Thu, 19 Sep 2024 08:21:42 +0300 Subject: [PATCH 1/3] Support synchronously metrics publishing --- .../otelawsmetrics/OtelMetricPublisher.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/appsflyer/otelawsmetrics/OtelMetricPublisher.java b/src/main/java/com/appsflyer/otelawsmetrics/OtelMetricPublisher.java index 4b2409b..c72ba6c 100644 --- a/src/main/java/com/appsflyer/otelawsmetrics/OtelMetricPublisher.java +++ b/src/main/java/com/appsflyer/otelawsmetrics/OtelMetricPublisher.java @@ -13,6 +13,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executor; import java.util.concurrent.ForkJoinPool; @@ -45,6 +46,13 @@ public OtelMetricPublisher(OpenTelemetry openTelemetry, String metricPrefix) { } public OtelMetricPublisher(OpenTelemetry openTelemetry, String metricPrefix, Executor executor) { + Objects.requireNonNull(metricPrefix, "metricPrefix must not be null"); + Objects.requireNonNull(openTelemetry, "openTelemetry must not be null"); + + if (executor == null) { + log.warn("An executor is not provided. The metrics will be published synchronously on the calling thread."); + } + this.metricPrefix = metricPrefix + "."; this.executor = executor; @@ -57,6 +65,11 @@ public OtelMetricPublisher(OpenTelemetry openTelemetry, String metricPrefix, Exe @Override public void publish(MetricCollection metricCollection) { + if (executor == null) { + publishInternal(metricCollection); + return; + } + try { executor.execute(() -> publishInternal(metricCollection)); } catch (RejectedExecutionException ex) { From 5ce133da4d908fe0b00295d0b8dd687b2e79a4f5 Mon Sep 17 00:00:00 2001 From: Yevgeni Tsodikov Date: Thu, 19 Sep 2024 08:25:02 +0300 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8210336..9008e56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.1] - 2024-09-19 + +### Changed + +- Support for a null `executor`, allowing for synchronous metrics publishing. +- Verify `openTelemetry` and `metricPrefix` are not null in the `OtelMetricPublisher` constructor. + ## [1.0.0] - 2024-09-17 ### Added - Initial release of the AWS SDK Java OpenTelemetry Metrics library. +[1.0.1]: https://github.com/AppsFlyer/aws-sdk-java-opentelemetry-metrics/pull/18 + [1.0.0]: https://github.com/olivierlacan/keep-a-changelog/releases/tag/v1.0.0 From d983ff9357321b213dbece8f0be4582b0faccb94 Mon Sep 17 00:00:00 2001 From: Yevgeni Tsodikov Date: Thu, 19 Sep 2024 09:18:30 +0300 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9008e56..0b206cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial release of the AWS SDK Java OpenTelemetry Metrics library. -[1.0.1]: https://github.com/AppsFlyer/aws-sdk-java-opentelemetry-metrics/pull/18 +[1.0.1]: https://github.com/AppsFlyer/aws-sdk-java-opentelemetry-metrics/compare/aws-sdk-java-opentelemetry-metrics-1.0.0...aws-sdk-java-opentelemetry-metrics-1.0.1 -[1.0.0]: https://github.com/olivierlacan/keep-a-changelog/releases/tag/v1.0.0 +[1.0.0]: https://github.com/AppsFlyer/aws-sdk-java-opentelemetry-metrics/releases/tag/aws-sdk-java-opentelemetry-metrics-1.0.0