From a22690c9ca3fe6f491d0cf980dba69ecc8b9bdc2 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Tue, 5 May 2020 19:24:26 -0500 Subject: [PATCH] [7.x] Ensure that the monitoring export exceptions are logged. (#56237) (#56251) If an exception occurs while flushing a bulk the cause of the exception can be lost. This commit ensures that cause of the exception is carried forward and gets logged. --- .../xpack/monitoring/exporter/ExportBulk.java | 2 +- .../elasticsearch/xpack/monitoring/exporter/Exporters.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportBulk.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportBulk.java index 938f0f57c26..f2b36620010 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportBulk.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ExportBulk.java @@ -88,7 +88,7 @@ public abstract class ExportBulk { bulk.add(docs); } catch (ExportException e) { if (exception == null) { - exception = new ExportException("failed to add documents to export bulks"); + exception = new ExportException("failed to add documents to export bulks", e); } exception.addExportException(e); } diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporters.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporters.java index aa10f4821e0..7cff593def8 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporters.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporters.java @@ -243,7 +243,12 @@ public class Exporters extends AbstractLifecycleComponent { } else { listener.onFailure(exceptionRef.get()); } - }, listener::onFailure)); + }, (exception) -> { + if (exceptionRef.get() != null) { + exception.addSuppressed(exceptionRef.get()); + } + listener.onFailure(exception); + })); } }