From 20f79196ca623bd51c2ce4d2a9424eab2fbee2aa Mon Sep 17 00:00:00 2001 From: Kostas Krikellas <131142368+kkrik-es@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:47:02 +0200 Subject: [PATCH] Log message for doc parsing errors includes index name (#118347) (#118416) * Throttled doc parsing error logging * add test * move throttler to separate class * small changes * refactor unittest * fix test * Log message for doc parsing errors includes index name (cherry picked from commit 85f37aca7921e9a7f9360a92ea5fbfe86f9667ee) # Conflicts: # server/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java --- .../java/org/elasticsearch/index/mapper/DocumentMapper.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java index c56885eded38f..ecc4b92f369d6 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java @@ -30,6 +30,7 @@ public class DocumentMapper { private final MapperMetrics mapperMetrics; private final IndexVersion indexVersion; private final Logger logger; + private final String indexName; /** * Create a new {@link DocumentMapper} that holds empty mappings. @@ -67,6 +68,7 @@ public static DocumentMapper createEmpty(MapperService mapperService) { this.mapperMetrics = mapperMetrics; this.indexVersion = version; this.logger = Loggers.getLogger(getClass(), indexName); + this.indexName = indexName; assert mapping.toCompressedXContent().equals(source) || isSyntheticSourceMalformed(source, version) : "provided source [" + source + "] differs from mapping [" + mapping.toCompressedXContent() + "]"; @@ -74,9 +76,9 @@ public static DocumentMapper createEmpty(MapperService mapperService) { private void maybeLog(Exception ex) { if (logger.isDebugEnabled()) { - logger.debug("Error while parsing document: " + ex.getMessage(), ex); + logger.debug("Error while parsing document for index [" + indexName + "]: " + ex.getMessage(), ex); } else if (IntervalThrottler.DOCUMENT_PARSING_FAILURE.accept()) { - logger.error("Error while parsing document: " + ex.getMessage(), ex); + logger.info("Error while parsing document for index [" + indexName + "]: " + ex.getMessage(), ex); } }