This is an automated email from the ASF dual-hosted git repository.

cecemei pushed a commit to branch 37.0.0
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/37.0.0 by this push:
     new 13da69b9ea7 fix: package logging emitter resource and rename to avoid 
classpath issues (#19359) (#19371)
13da69b9ea7 is described below

commit 13da69b9ea75a7d56d6ecf60be0c7892e68a9cfb
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Apr 24 09:22:56 2026 -0700

    fix: package logging emitter resource and rename to avoid classpath issues 
(#19359) (#19371)
    
    The previous fix broadly added src/main/resources as a resource directory,
    which inadvertently packaged log4j2.xml, log4j2.debug.xml, and the
    services/javax.annotation.processing.Processor file into 
druid-processing.jar.
    
    The packaged log4j2.xml (console-only) ends up on the classpath of dependent
    modules like indexing-service and shadows processing's test log4j2.xml that
    contains the RoutingAppender used to route task logs to per-task files. This
    caused 
ThreadingTaskRunnerTest#test_streamTaskLogs_ofRunningTask_readsFromTaskLogFile
    to fail because the per-task log file was never written.
    
    Narrow the include to only loggingEmitterAllowedMetrics.json so behavior for
    every other file in processing/src/main/resources matches pre-PR state.
    
    
    (cherry picked from commit 2de75ab1d74c8ba6c9623654cb69f9cd71442007)
    
    Co-authored-by: sarangv <[email protected]>
    Co-authored-by: Sarang Vadali <[email protected]>
---
 docs/configuration/index.md                               |  2 +-
 processing/pom.xml                                        |  6 ++++++
 .../druid/java/util/emitter/core/LoggingEmitter.java      | 15 ++++++++-------
 .../java/util/emitter/core/LoggingEmitterConfig.java      |  8 ++++----
 ...aultMetrics.json => loggingEmitterAllowedMetrics.json} |  0
 .../druid/java/util/emitter/core/LoggingEmitterTest.java  |  4 ++--
 ...aultMetrics.json => loggingEmitterAllowedMetrics.json} |  0
 7 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/docs/configuration/index.md b/docs/configuration/index.md
index 172d8062a5e..08486e21a52 100644
--- a/docs/configuration/index.md
+++ b/docs/configuration/index.md
@@ -2022,7 +2022,7 @@ log4j config to route these logs to different sources 
based on the feed of the e
 |`druid.emitter.logging.loggerClass`|The class used for 
logging.|`org.apache.druid.java.util.emitter.core.LoggingEmitter`|
 |`druid.emitter.logging.logLevel`|Choices: debug, info, warn, error. The log 
level at which message are logged.|info|
 |`druid.emitter.logging.shouldFilterMetrics`|When true, only metrics listed in 
the allow list are emitted; non-metric events (e.g. alerts) are always emitted. 
When false, all events are logged (backward-compatible).|false|
-|`druid.emitter.logging.allowedMetricsPath`|Path to a JSON file whose keys are 
the allowed metric names. Only used when `shouldFilterMetrics` is true. If null 
or empty, the bundled classpath resource `defaultMetrics.json` is used. If a 
path is set but the file is missing, a warning is logged and the emitter falls 
back to the default classpath resource.|null|
+|`druid.emitter.logging.allowedMetricsPath`|Path to a JSON file whose keys are 
the allowed metric names. Only used when `shouldFilterMetrics` is true. If null 
or empty, the bundled classpath resource `loggingEmitterAllowedMetrics.json` is 
used. If a path is set but the file is missing, a warning is logged and the 
emitter falls back to the default classpath resource.|null|
 
 #### HTTP emitter module
 
diff --git a/processing/pom.xml b/processing/pom.xml
index dcc9da8a5de..424591dea2f 100644
--- a/processing/pom.xml
+++ b/processing/pom.xml
@@ -531,6 +531,12 @@
     </plugins>
 
     <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+        <includes>
+          <include>loggingEmitterAllowedMetrics.json</include>
+        </includes>
+      </resource>
       <resource>
         <directory>
           
${project.build.directory}/hyperic-sigar-${sigar.base.version}/sigar-bin/lib
diff --git 
a/processing/src/main/java/org/apache/druid/java/util/emitter/core/LoggingEmitter.java
 
b/processing/src/main/java/org/apache/druid/java/util/emitter/core/LoggingEmitter.java
index 17392515dd6..e53977adc8c 100644
--- 
a/processing/src/main/java/org/apache/druid/java/util/emitter/core/LoggingEmitter.java
+++ 
b/processing/src/main/java/org/apache/druid/java/util/emitter/core/LoggingEmitter.java
@@ -50,7 +50,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 public class LoggingEmitter implements Emitter
 {
   private static final Logger LOGGER = new Logger(LoggingEmitter.class);
-  private static final String DEFAULT_ALLOWED_METRICS_RESOURCE = 
"defaultMetrics.json";
+  private static final String DEFAULT_ALLOWED_METRICS_RESOURCE = 
"loggingEmitterAllowedMetrics.json";
 
   private final Logger log;
   private final Level level;
@@ -92,9 +92,9 @@ public class LoggingEmitter implements Emitter
 
   /**
    * Loads the allowed metric names from a JSON file. If the path is null or 
empty,
-   * loads from the bundled classpath resource (defaultMetrics.json). If a 
custom
-   * path is provided but the file is missing, logs a warning and falls back to
-   * the default classpath resource.
+   * loads from the bundled classpath resource 
(loggingEmitterAllowedMetrics.json).
+   * If a custom path is provided but the file is missing, logs a warning and 
falls
+   * back to the default classpath resource.
    */
   private static Set<String> loadAllowedMetrics(@Nullable String path, 
ObjectMapper jsonMapper)
   {
@@ -112,9 +112,10 @@ public class LoggingEmitter implements Emitter
   }
 
   /**
-   * Opens the allowed metrics configuration stream. Uses classpath resource 
when
-   * path is null/empty. When a custom path is specified but the file is 
missing,
-   * logs a warning and falls back to the default classpath resource.
+   * Opens the allowed metrics configuration stream. Uses the bundled
+   * loggingEmitterAllowedMetrics.json classpath resource when path is 
null/empty.
+   * When a custom path is specified but the file is missing, logs a warning 
and
+   * falls back to the default classpath resource.
    */
   private static InputStream openAllowedMetricsStream(@Nullable String path)
   {
diff --git 
a/processing/src/main/java/org/apache/druid/java/util/emitter/core/LoggingEmitterConfig.java
 
b/processing/src/main/java/org/apache/druid/java/util/emitter/core/LoggingEmitterConfig.java
index 7aa3d579749..8f7be9f6bdb 100644
--- 
a/processing/src/main/java/org/apache/druid/java/util/emitter/core/LoggingEmitterConfig.java
+++ 
b/processing/src/main/java/org/apache/druid/java/util/emitter/core/LoggingEmitterConfig.java
@@ -39,8 +39,8 @@ public class LoggingEmitterConfig
   /**
    * When true, only metrics listed in the allowed metrics configuration are 
emitted.
    * If {@link #allowedMetricsPath} is null/empty, the bundled default 
allowlist
-   * (defaultMetrics.json on the classpath) is used. If a path is provided,
-   * it is loaded from that file instead.
+   * (loggingEmitterAllowedMetrics.json on the classpath) is used. If a path is
+   * provided, it is loaded from that file instead.
    * Defaults to false (emit all metrics, backward-compatible behavior).
    */
   @JsonProperty("shouldFilterMetrics")
@@ -49,8 +49,8 @@ public class LoggingEmitterConfig
   /**
    * Optional path to a JSON file containing an array of allowed metric names.
    * Only used when {@link #shouldFilterMetrics} is true.
-   * If null or empty, the bundled default resource (defaultMetrics.json) is 
loaded
-   * from the classpath, mirroring how the Prometheus emitter loads its 
defaultMetrics.json.
+   * If null or empty, the bundled default resource 
(loggingEmitterAllowedMetrics.json)
+   * is loaded from the classpath.
    */
   @JsonProperty
   @Nullable
diff --git a/processing/src/main/resources/defaultMetrics.json 
b/processing/src/main/resources/loggingEmitterAllowedMetrics.json
similarity index 100%
rename from processing/src/main/resources/defaultMetrics.json
rename to processing/src/main/resources/loggingEmitterAllowedMetrics.json
diff --git 
a/processing/src/test/java/org/apache/druid/java/util/emitter/core/LoggingEmitterTest.java
 
b/processing/src/test/java/org/apache/druid/java/util/emitter/core/LoggingEmitterTest.java
index b29cf44ef41..6aef81b0455 100644
--- 
a/processing/src/test/java/org/apache/druid/java/util/emitter/core/LoggingEmitterTest.java
+++ 
b/processing/src/test/java/org/apache/druid/java/util/emitter/core/LoggingEmitterTest.java
@@ -108,8 +108,8 @@ public class LoggingEmitterTest
 
   /**
    * With filtering enabled and no custom path, the default classpath resource
-   * (defaultMetrics.json) should be loaded. Metrics in the default list
-   * are emitted; unlisted metrics are dropped.
+   * (loggingEmitterAllowedMetrics.json) should be loaded. Metrics in the 
default
+   * list are emitted; unlisted metrics are dropped.
    */
   @Test
   public void testFilterWithDefaultResource()
diff --git a/processing/src/test/resources/defaultMetrics.json 
b/processing/src/test/resources/loggingEmitterAllowedMetrics.json
similarity index 100%
rename from processing/src/test/resources/defaultMetrics.json
rename to processing/src/test/resources/loggingEmitterAllowedMetrics.json


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to