coderzc commented on code in PR #24991:
URL: https://github.com/apache/pulsar/pull/24991#discussion_r2694393690


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -5466,4 +5466,86 @@ private static Long getIndexFromEntry(Entry entry) {
             }
         });
     }
+
+    protected CompletableFuture<Void> 
internalSetCustomMetricLabels(Map<String, String> labels, boolean isGlobal) {
+        // Feature flag check
+        if 
(!pulsar().getConfiguration().isExposeCustomTopicMetricLabelsEnabled()) {
+            return FutureUtil.failedFuture(new 
RestException(Status.PRECONDITION_FAILED,
+                    "Custom topic metric labels feature is disabled"));
+        }
+
+        // Validate labels against allowed keys and value length
+        Set<String> allowedKeys = getAllowedCustomMetricLabelKeys();
+        int maxValueLength = 
pulsar().getConfiguration().getMaxCustomMetricLabelValueLength();
+
+        if (labels != null && !labels.isEmpty()) {
+            for (Map.Entry<String, String> entry : labels.entrySet()) {
+                String key = entry.getKey();
+                String value = entry.getValue();
+
+                // Check if key is allowed
+                if (allowedKeys.isEmpty() || !allowedKeys.contains(key)) {

Review Comment:
   All keys should be rejected by default.



-- 
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]

Reply via email to