exceptionfactory commented on code in PR #10655: URL: https://github.com/apache/nifi/pull/10655#discussion_r2636743356
########## nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/VersionInfoRegistry.java: ########## @@ -0,0 +1,101 @@ +/* + * 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() { + // Processor / Process Group metrics + nameToGaugeMap.put("NIFI_VERSION_INFO", Gauge.build() + .name("nifi_version_info") + .help("NiFi framework and environment version information.") + .labelNames("instance_id", "nifi_version", "java_version", "revision", "build_tag", + "build_branch", "os_name", "os_version", "os_architecture", "java_vendor") + .register(registry)); + } + + @Override + public CollectorRegistry getRegistry() { + return registry; + } + public static class VersionDetails { + + public final String nifiVersion; + public final String revision; + public final String tag; + public final String buildBranch; + public final String javaVersion; + public final String javaVendor; + public final String osVersion; + public final String osName; + public final String osArchitecture; Review Comment: Instead of a class with `public` variables, this should be a `record`. ########## nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/VersionInfoRegistry.java: ########## @@ -0,0 +1,101 @@ +/* + * 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() { + // Processor / Process Group metrics + nameToGaugeMap.put("NIFI_VERSION_INFO", Gauge.build() + .name("nifi_version_info") + .help("NiFi framework and environment version information.") + .labelNames("instance_id", "nifi_version", "java_version", "revision", "build_tag", + "build_branch", "os_name", "os_version", "os_architecture", "java_vendor") + .register(registry)); + } + + @Override + public CollectorRegistry getRegistry() { + return registry; + } + public static class VersionDetails { + + public final String nifiVersion; Review Comment: I recommend calling this `frameworkVersion` since the API version can be different. ########## nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/PrometheusMetricsUtil.java: ########## @@ -478,6 +478,14 @@ 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.nifiVersion, details.javaVersion, details.revision, details.tag, + details.buildBranch, details.osName, details.osVersion, details.osArchitecture, details.javaVendor); +} Review Comment: It looks like this block needs to be indented. ########## nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/VersionInfoRegistry.java: ########## @@ -0,0 +1,101 @@ +/* + * 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() { + // Processor / Process Group metrics + nameToGaugeMap.put("NIFI_VERSION_INFO", Gauge.build() + .name("nifi_version_info") + .help("NiFi framework and environment version information.") + .labelNames("instance_id", "nifi_version", "java_version", "revision", "build_tag", Review Comment: ```suggestion .labelNames("instance_id", "framework_version", "java_version", "revision", "build_tag", ``` ########## nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/VersionInfoRegistry.java: ########## @@ -0,0 +1,101 @@ +/* + * 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() { + // Processor / Process Group metrics + nameToGaugeMap.put("NIFI_VERSION_INFO", Gauge.build() + .name("nifi_version_info") + .help("NiFi framework and environment version information.") + .labelNames("instance_id", "nifi_version", "java_version", "revision", "build_tag", + "build_branch", "os_name", "os_version", "os_architecture", "java_vendor") + .register(registry)); Review Comment: It would be helpful to format this list with one item per line for readability. ########## nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/VersionInfoRegistry.java: ########## @@ -0,0 +1,101 @@ +/* + * 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() { + // Processor / Process Group metrics Review Comment: This comment does not match the content and should be removed. -- 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]
