diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md index 1db6175a75e89..a9c584ff8b0b1 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md @@ -7,6 +7,7 @@ ### Breaking Changes ### Bugs Fixed +- [Fix flush on JVM shutdown](https://github.com/Azure/azure-sdk-for-java/pull/37618) ### Other Changes diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/pipeline/TelemetryItemExporter.java b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/pipeline/TelemetryItemExporter.java index f422cdbf3be59..7e4c73b9f58d5 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/pipeline/TelemetryItemExporter.java +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/pipeline/TelemetryItemExporter.java @@ -85,7 +85,8 @@ public CompletableResultCode send(List telemetryItems) { for (Map.Entry> batch : batches.entrySet()) { resultCodeList.add(internalSendByBatch(batch.getKey(), batch.getValue())); } - return maybeAddToActiveExportResults(resultCodeList); + maybeAddToActiveExportResults(resultCodeList); + return CompletableResultCode.ofAll(resultCodeList); } // visible for tests @@ -106,14 +107,13 @@ Map> splitIntoBatches( return groupings; } - private CompletableResultCode maybeAddToActiveExportResults(List results) { + private void maybeAddToActiveExportResults(List results) { if (activeExportResults.size() >= MAX_CONCURRENT_EXPORTS) { // this is just a failsafe to limit concurrent exports, it's not ideal because it blocks // waiting for the most recent export instead of waiting for the first export to return operationLogger.recordFailure( "Hit max " + MAX_CONCURRENT_EXPORTS + " active concurrent requests", TELEMETRY_ITEM_EXPORTER_ERROR); - return CompletableResultCode.ofAll(results); } operationLogger.recordSuccess(); @@ -122,8 +122,6 @@ private CompletableResultCode maybeAddToActiveExportResults(List activeExportResults.remove(result)); } - - return CompletableResultCode.ofSuccess(); } public CompletableResultCode flush() {