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.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 @@ 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. + * 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 +}