Skip to content

NIFI-16072 Add ProcessSessionEvent handling to ComponentMetricReporter#11398

Merged
pvillard31 merged 3 commits into
apache:mainfrom
exceptionfactory:NIFI-16072
Jul 7, 2026
Merged

NIFI-16072 Add ProcessSessionEvent handling to ComponentMetricReporter#11398
pvillard31 merged 3 commits into
apache:mainfrom
exceptionfactory:NIFI-16072

Conversation

@exceptionfactory

Copy link
Copy Markdown
Contributor

Summary

NIFI-16072 Continues incremental framework adjustments initiated under NIP-19 to support recording gauge values. The current set of changes adds a recordProcessSessionEvent() method to the ComponentMetricReporter interface defined in nifi-framework-api. This additional method aligns metrics collection in ProcessSession implementations to include Counters, Gauges, and FlowFile handling operations.

The majority of the changes relate to renaming and moving the FlowFileEvent interface from nifi-framework-components to nifi-framework-api. The interface name is now ProcessSessionEvent, aligning more closely with the scope of behavior tracked. The interface itself is moved to nifi-framework-api to align with the location of the ComponentMetricReporter.

The addition of the recordProcessSessionEvent() method includes a default implementation with no operations, making it compatible with existing framework extension classes and also making it optional for framework extensions.

The move from FlowFileEvent to ProcessSessionEvent avoids duplicative object creation, and the new method provides clean decoupling of reporting FlowFile metrics from the volatile or persistent storage of such metrics in the StatusHistoryRepository. Minor adjustments to ProcessSessionEvent include correcting the method name of getGarbageCollectionMillis and removing the getAverageLineageMillis() in favor of localized calculation where needed.

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 contains commits signed with a registered key indicating Verified status

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

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using ./mvnw clean install -P contrib-check
    • JDK 21
    • JDK 25

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

- Renamed FlowFileEvent to ProcessSessionEvent
- Moved ProcessSessionEvent to framework-api for ComponentMetricReporter
- Added recordProcessSessionEvent method to RepositoryContext
connectionEvent.setContentSizeOut(connectionEvent.getContentSizeOut() + bytes);
connectionEvent.setFlowFilesOut(connectionEvent.getFlowFilesOut() + flowFileCount);
final ProcessSessionEventBuilder connectionEvent = connectionCounts.computeIfAbsent(
connectionId, id -> ProcessSessionEventBuilder.forComponent(getConnectionMetricContext(connectionId)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the id-only incrementConnectionOutputCounts used by migrate(), is the fallback context (name equal to id, no group attributes) intended for the destination session that never cached the connection?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, since the previous behavior did not include the name or attributes, the Connection MetricContext with reused id appears to be the best option, unless there is another clear way to get the needed Connection object for the new owner.

@exceptionfactory

Copy link
Copy Markdown
Contributor Author

Thanks for the review @pvillard31, I pushed an update with some additional tests to verify the invocation of recordProcessSessionEvent()

@pvillard31 pvillard31 merged commit a2760cd into apache:main Jul 7, 2026
13 of 14 checks passed
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