Skip to content

Conversation

@exceptionfactory
Copy link
Contributor

Summary

NIFI-15477 Adds the recordGauge method to the ProcessSession interface as described in NIP-19 .

The default implementation is empty, which will allow the NiFi API to be released and upgraded without having to make simultaneous changes to implement the new method.

The method signature follows the pattern of adjustCounter, but uses the CommitTiming enumeration for clarity of reading and writing calls in Processors, as opposed to a boolean flag.

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Comment on lines +256 to +257
/**
* Record measurement value for the named Gauge, registering the named Gauge when not present in the system.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be useful addition in the javadoc for developers not familiar with the terminology

Suggested change
/**
* Record measurement value for the named Gauge, registering the named Gauge when not present in the system.
/**
* Record measurement value for the named Gauge, registering the named Gauge when not present in the system.
* Unlike counters which track cumulative values, gauges represent point-in-time measurements that can increase or decrease.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that is a helpful clarification to distinguish it from counters.

* @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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to also have a convenience method like

default void recordGauge(String name, double value) {
    recordGauge(name, value, CommitTiming.SESSION_COMMITTED);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered that possibility, but I could also see an argument for making NOW the default option. In the end, I think it is best to follow the pattern of adjustCounter, and require the argument in all cases.

* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.processor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the best package location in case it should apply to other components in the future? Maybe org.apache.nifi.metrics?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like a better fit under the processor package, since it is used directly in ProcessSession, and I would not expect this to be used outside the scope of ProcessSession. The same package also has DataUnit as an enum. I considered processor.metrics as a new package, but it would be the only member. I'll move it to processor.metrics.

@exceptionfactory exceptionfactory marked this pull request as ready for review January 19, 2026 19:07
@exceptionfactory
Copy link
Contributor Author

Thanks again for the review @pvillard31! I marked this as ready for review following the passing vote thread for NIP-19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants