Skip to content

Commit b3c3d3d

Browse files
exceptionfactorypvillard31
authored andcommitted
NIFI-15477 Added recordGauge method to ProcessSession
This closes #49. Signed-off-by: Pierre Villard <[email protected]>
1 parent a50a385 commit b3c3d3d

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/main/java/org/apache/nifi/processor/ProcessSession.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.nifi.processor.io.InputStreamCallback;
3838
import org.apache.nifi.processor.io.OutputStreamCallback;
3939
import org.apache.nifi.processor.io.StreamCallback;
40+
import org.apache.nifi.processor.metrics.CommitTiming;
4041
import org.apache.nifi.provenance.ProvenanceReporter;
4142
import org.apache.nifi.provenance.ProvenanceEventType;
4243

@@ -253,6 +254,18 @@ default void commitAsync(Runnable onSuccess) {
253254
*/
254255
void adjustCounter(String name, long delta, boolean immediate);
255256

257+
/**
258+
* Record measurement value for the named Gauge, registering the named Gauge when not present in the system.
259+
* Gauges represent a measurement at a point in time, unlike counters that track cumulative values.
260+
*
261+
* @param name Gauge name to update or register
262+
* @param value Measurement value to record
263+
* @param commitTiming Timing for when the measurement value should be committed
264+
*/
265+
default void recordGauge(String name, double value, CommitTiming commitTiming) {
266+
267+
}
268+
256269
/**
257270
* Returns the {@link FlowFile} from the work queue that is next highest priority to process.
258271
* If no FlowFiles are available, returns {@code null}.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.nifi.processor.metrics;
18+
19+
/**
20+
* Enumeration of timing options for committing metrics
21+
*/
22+
public enum CommitTiming {
23+
/** Commit metrics immediately regardless of session transaction status */
24+
NOW,
25+
26+
/** Commit metrics on successful commit of session transaction */
27+
SESSION_COMMITTED
28+
}

0 commit comments

Comments
 (0)