exceptionfactory commented on code in PR #10501:
URL: https://github.com/apache/nifi/pull/10501#discussion_r2534362198


##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java:
##########
@@ -578,13 +579,19 @@ public Response getFlowMetrics(
             @Parameter(
                     description = "Name of the first field of JSON object. 
Applicable for JSON producer only."
             )
-            @QueryParam("rootFieldName") final String rootFieldName
-    ) {
+            @QueryParam("rootFieldName") final String rootFieldName,
+            @Parameter(
+                    description = "Flow metrics reporting strategy lets you 
optionally limit what metrics are collected"

Review Comment:
   It is best to avoid direct references such as `you` in descriptions:
   
   ```suggestion
                       description = "Flow metrics reporting strategy limits 
collected metrics"
   ```



##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java:
##########
@@ -408,7 +408,7 @@ public interface NiFiServiceFacade {
      * @param includeRegistries Set of Flow Metrics Registries to be returned
      * @return Collector Registries
      */
-    Collection<CollectorRegistry> generateFlowMetrics(Set<FlowMetricsRegistry> 
includeRegistries);
+    Collection<CollectorRegistry> generateFlowMetrics(Set<FlowMetricsRegistry> 
includeRegistries, String flowMetricsStrategy);

Review Comment:
   Instead of passing the `String` it would be better to pass the enum 
`FlowMetricsReportingStrategy`:
   
   ```suggestion
       Collection<CollectorRegistry> 
generateFlowMetrics(Set<FlowMetricsRegistry> includeRegistries, 
FlowMetricsReportingStrategy flowMetricsStrategy);
   ```



##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/request/FlowMetricsReportingStrategy.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.nifi.web.api.request;
+
+
+import org.apache.nifi.components.AllowableValue;
+
+import static 
org.apache.nifi.prometheusutil.PrometheusMetricsUtil.METRICS_STRATEGY_COMPONENTS;
+import static 
org.apache.nifi.prometheusutil.PrometheusMetricsUtil.METRICS_STRATEGY_PG;
+
+public enum FlowMetricsReportingStrategy {
+    ONLY_PROCESS_GROUPS(METRICS_STRATEGY_PG),

Review Comment:
   The display name for `METRICS_STRATEGY_PG` is `All Process Groups`, so it 
would be better to align this `enum` name:
   
   ```suggestion
       ALL_PROCESS_GROUPS(METRICS_STRATEGY_PG),
   ```



##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java:
##########
@@ -408,7 +408,7 @@ public interface NiFiServiceFacade {
      * @param includeRegistries Set of Flow Metrics Registries to be returned

Review Comment:
   The parameter documentation should be updated



##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java:
##########
@@ -6633,7 +6633,7 @@ public ProcessorDiagnosticsEntity 
getProcessorDiagnostics(final String id) {
         return entityFactory.createProcessorDiagnosticsEntity(dto, 
revisionDto, permissionsDto, processorStatusDto, bulletins);
     }
 
-    protected Collection<AbstractMetricsRegistry> populateFlowMetrics() {
+    protected Collection<AbstractMetricsRegistry> populateFlowMetrics(String 
flowMetricsStrategy) {

Review Comment:
   The `enum` should be passed to this method



##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/request/FlowMetricsReportingStrategy.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.nifi.web.api.request;
+
+
+import org.apache.nifi.components.AllowableValue;
+
+import static 
org.apache.nifi.prometheusutil.PrometheusMetricsUtil.METRICS_STRATEGY_COMPONENTS;
+import static 
org.apache.nifi.prometheusutil.PrometheusMetricsUtil.METRICS_STRATEGY_PG;
+
+public enum FlowMetricsReportingStrategy {
+    ONLY_PROCESS_GROUPS(METRICS_STRATEGY_PG),
+    ALL_COMPONENTS(METRICS_STRATEGY_COMPONENTS);
+
+    private final AllowableValue strategy;
+
+    FlowMetricsReportingStrategy(final AllowableValue strategy) {
+        this.strategy = strategy;
+    }
+
+    public AllowableValue getStrategy() {

Review Comment:
   Instead of having `getStrategy()` return an `AllowableValue`, this enum can 
implement `DescribedValue` and use the values from `METRICS_STRATEGY_PG` and 
`METRICS_STRATEGY_COMPONENTS` to return the matching Strings for `getValue()`.



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