pvillard31 commented on code in PR #10655:
URL: https://github.com/apache/nifi/pull/10655#discussion_r2652699791


##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/VersionInfoRegistry.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.prometheusutil;
+import io.prometheus.client.CollectorRegistry;
+import io.prometheus.client.Gauge;
+import org.apache.nifi.nar.NarClassLoadersHolder;
+import org.apache.nifi.bundle.Bundle;
+import org.apache.nifi.bundle.BundleDetails;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class VersionInfoRegistry extends AbstractMetricsRegistry {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(VersionInfoRegistry.class);
+    private static final String DEFAULT_LABEL_STRING = "unknown";
+
+    public VersionInfoRegistry() {
+        nameToGaugeMap.put("NIFI_VERSION_INFO", Gauge.build()
+            .name("nifi_version_info")
+            .help("NiFi framework and environment version information.")
+            .labelNames(
+                "instance_id",
+                "framework_version",
+                "java_version",
+                "revision",
+                "build_tag",
+                "build_branch",
+                "os_name",
+                "os_version",
+                "os_architecture",
+                "java_vendor"
+            )
+            .register(registry)
+        );
+    }
+
+    @Override
+    public CollectorRegistry getRegistry() {
+        return registry;
+    }
+

Review Comment:
   ```suggestion
   ```
   
   Can be removed as there is the same implementation in the parent class.



##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/PrometheusMetricsUtil.java:
##########
@@ -478,6 +478,26 @@ public static CollectorRegistry 
createAggregatedNifiMetrics(final NiFiMetricsReg
         return niFiMetricsRegistry.getRegistry();
     }
 
+    public static void createVersionInfoMetrics(final VersionInfoRegistry 
versionInfoRegistry, final String instanceId) {
+    // 1. Retrieve the calculated version details
+        final VersionInfoRegistry.VersionDetails details = 
versionInfoRegistry.getVersionDetails();
+
+        versionInfoRegistry.setDataPoint(
+                1,
+                "NIFI_VERSION_INFO",
+                instanceId,
+                details.frameworkVersion(),
+                details.javaVersion(),
+                details.revision(),
+                details.tag(),
+                details.buildBranch(),
+                details.osName(),
+                details.osVersion(),
+                details.osArchitecture(),
+                details.javaVendor()
+        );
+}

Review Comment:
   ```suggestion
       public static void createVersionInfoMetrics(final VersionInfoRegistry 
versionInfoRegistry, final String instanceId) {
           // Retrieve the calculated version details
           final VersionInfoRegistry.VersionDetails details = 
versionInfoRegistry.getVersionDetails();
   
           versionInfoRegistry.setDataPoint(
                   1,
                   "NIFI_VERSION_INFO",
                   instanceId,
                   details.frameworkVersion(),
                   details.javaVersion(),
                   details.revision(),
                   details.tag(),
                   details.buildBranch(),
                   details.osName(),
                   details.osVersion(),
                   details.osArchitecture(),
                   details.javaVendor()
           );
       }
   ```



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