This is an automated email from the ASF dual-hosted git repository.
pvillard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-api.git
The following commit(s) were added to refs/heads/main by this push:
new b3c3d3d NIFI-15477 Added recordGauge method to ProcessSession
b3c3d3d is described below
commit b3c3d3da1adb5b669c2793d0b9dc470a9021a78d
Author: exceptionfactory <[email protected]>
AuthorDate: Thu Jan 15 11:29:39 2026 -0600
NIFI-15477 Added recordGauge method to ProcessSession
This closes #49.
Signed-off-by: Pierre Villard <[email protected]>
---
.../org/apache/nifi/processor/ProcessSession.java | 13 ++++++++++
.../nifi/processor/metrics/CommitTiming.java | 28 ++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/src/main/java/org/apache/nifi/processor/ProcessSession.java
b/src/main/java/org/apache/nifi/processor/ProcessSession.java
index 26106b1..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.exception.ProcessException;
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;
@@ -253,6 +254,18 @@ public interface ProcessSession {
*/
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.
+ * 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
+ * @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}.
diff --git a/src/main/java/org/apache/nifi/processor/metrics/CommitTiming.java
b/src/main/java/org/apache/nifi/processor/metrics/CommitTiming.java
new file mode 100644
index 0000000..9015886
--- /dev/null
+++ b/src/main/java/org/apache/nifi/processor/metrics/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.metrics;
+
+/**
+ * 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
+}