From efe4f559cb5edad2b34ac0869d28d45475e6759c Mon Sep 17 00:00:00 2001 From: exceptionfactory Date: Thu, 15 Jan 2026 11:29:39 -0600 Subject: [PATCH 1/2] NIFI-15477 Added recordGauge method to ProcessSession --- .../apache/nifi/processor/CommitTiming.java | 28 +++++++++++++++++++ .../apache/nifi/processor/ProcessSession.java | 11 ++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/main/java/org/apache/nifi/processor/CommitTiming.java diff --git a/src/main/java/org/apache/nifi/processor/CommitTiming.java b/src/main/java/org/apache/nifi/processor/CommitTiming.java new file mode 100644 index 0000000..e26917c --- /dev/null +++ b/src/main/java/org/apache/nifi/processor/CommitTiming.java @@ -0,0 +1,28 @@ +/* + * 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.processor; + +/** + * Enumeration of timing options for committing metrics + */ +public enum CommitTiming { + /** Commit metrics immediately regardless of session transaction status */ + NOW, + + /** Commit metrics on successful commit of session transaction */ + SESSION_COMMITTED +} diff --git a/src/main/java/org/apache/nifi/processor/ProcessSession.java b/src/main/java/org/apache/nifi/processor/ProcessSession.java index 26106b1..4e9aefa 100644 --- a/src/main/java/org/apache/nifi/processor/ProcessSession.java +++ b/src/main/java/org/apache/nifi/processor/ProcessSession.java @@ -253,6 +253,17 @@ default void commitAsync(Runnable onSuccess) { */ void adjustCounter(String name, long delta, boolean immediate); + /** + * Record measurement value for the named Gauge, registering the named Gauge when not present in the system. + * + * @param name Gauge name to update or register + * @param value Measurement value to record + * @param commitTiming Timing for when the measurement value should be committed + */ + default void recordGauge(String name, double value, CommitTiming commitTiming) { + + } + /** * Returns the {@link FlowFile} from the work queue that is next highest priority to process. * If no FlowFiles are available, returns {@code null}. From 4b9fd0c02420b538c21505ca1d826c7cf1a9a338 Mon Sep 17 00:00:00 2001 From: exceptionfactory Date: Fri, 16 Jan 2026 14:44:08 -0600 Subject: [PATCH 2/2] NIFI-15477 Moved CommitTiming to metrics package and updated comments --- src/main/java/org/apache/nifi/processor/ProcessSession.java | 2 ++ .../org/apache/nifi/processor/{ => metrics}/CommitTiming.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) rename src/main/java/org/apache/nifi/processor/{ => metrics}/CommitTiming.java (96%) diff --git a/src/main/java/org/apache/nifi/processor/ProcessSession.java b/src/main/java/org/apache/nifi/processor/ProcessSession.java index 4e9aefa..e0340a8 100644 --- a/src/main/java/org/apache/nifi/processor/ProcessSession.java +++ b/src/main/java/org/apache/nifi/processor/ProcessSession.java @@ -37,6 +37,7 @@ import org.apache.nifi.processor.io.InputStreamCallback; import org.apache.nifi.processor.io.OutputStreamCallback; import org.apache.nifi.processor.io.StreamCallback; +import org.apache.nifi.processor.metrics.CommitTiming; import org.apache.nifi.provenance.ProvenanceReporter; import org.apache.nifi.provenance.ProvenanceEventType; @@ -255,6 +256,7 @@ default void commitAsync(Runnable onSuccess) { /** * Record measurement value for the named Gauge, registering the named Gauge when not present in the system. + * Gauges represent a measurement at a point in time, unlike counters that track cumulative values. * * @param name Gauge name to update or register * @param value Measurement value to record diff --git a/src/main/java/org/apache/nifi/processor/CommitTiming.java b/src/main/java/org/apache/nifi/processor/metrics/CommitTiming.java similarity index 96% rename from src/main/java/org/apache/nifi/processor/CommitTiming.java rename to src/main/java/org/apache/nifi/processor/metrics/CommitTiming.java index e26917c..9015886 100644 --- a/src/main/java/org/apache/nifi/processor/CommitTiming.java +++ b/src/main/java/org/apache/nifi/processor/metrics/CommitTiming.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.nifi.processor; +package org.apache.nifi.processor.metrics; /** * Enumeration of timing options for committing metrics