FrankChen021 commented on code in PR #19026:
URL: https://github.com/apache/druid/pull/19026#discussion_r3141586189


##########
processing/src/main/java/org/apache/druid/java/util/emitter/core/GlobalEmitterConfig.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.java.util.emitter.core;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.Optional;
+
+/**
+ * Shared metric-filtering configuration for emitter implementations.
+ */
+public class GlobalEmitterConfig
+{
+  /**
+   * When true, only metrics listed in the allowed metrics configuration are 
emitted.
+   * If {@link #metricSpecPath} 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.
+   * Defaults to false (emit all metrics).
+   */
+  @JsonProperty
+  private boolean shouldFilterMetrics;
+
+  /**
+   * Optional path to a JSON file containing a JSON object keyed by allowed 
metric names,
+   * for example `{"query/time": [], "jvm/gc/cpu": []}`.
+   * Only used when {@link #shouldFilterMetrics} is true.
+   * If null or empty, the bundled default resource (`defaultMetrics.json`) is 
loaded
+   * from the classpath.
+   */
+  @JsonProperty
+  private String metricSpecPath;
+
+  public boolean isShouldFilterMetrics()
+  {
+    return shouldFilterMetrics;
+  }
+
+  public Optional<String> getMetricSpecPath()

Review Comment:
   P2 Treat empty metricSpecPath as absent
   
   The docs and class comment say null or empty metricSpecPath should use the 
bundled default, but this getter returns Optional.of(""). HTTP, parametrized 
URI, and Prometheus filtering then call loadAllowlistFromFile(""), where 
validation throws during emitter construction instead of loading the default. 
Normalize empty strings to Optional.empty() here, or before calling 
loadAllowedMetricNames, and add coverage for an empty configured path.



##########
processing/src/main/java/org/apache/druid/java/util/emitter/core/Emitters.java:
##########
@@ -145,9 +157,9 @@ static Map<String, Object> makeLoggingMap(Properties props)
           "shouldFilterMetrics", 
Boolean.parseBoolean(props.getProperty("org.apache.druid.java.util.emitter.logging.shouldFilterMetrics"))
       );
     }
-    if 
(props.containsKey("org.apache.druid.java.util.emitter.logging.allowedMetricsPath"))
 {
+    if 
(props.containsKey("org.apache.druid.java.util.emitter.logging.metricSpecPath"))
 {

Review Comment:
   P2 Keep the old logging allowlist property as an alias
   
   This drops support for 
org.apache.druid.java.util.emitter.logging.allowedMetricsPath, which was the 
documented property before this PR. Druid's DefaultObjectMapper ignores unknown 
properties, so existing configs with shouldFilterMetrics=true and the old path 
will silently ignore the custom allowlist and fall back to defaultMetrics.json, 
filtering out metrics operators expected to keep. Please accept the old 
property as a deprecated alias or migrate it explicitly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to