Mark Payne created NIP-53:
-----------------------------
Summary: Allow Connectors to record Counters and Gauges
Key: NIP-53
URL: https://issues.apache.org/jira/browse/NIP-53
Project: NiFi Improvement Proposal
Issue Type: Improvement
Reporter: Mark Payne
Assignee: Mark Payne
h2. Motivation
Processors can report Counters and Gauges through the ProcessSession
(adjustCounter and recordGauge). The framework sends these values to the
configured ComponentMetricReporter, and Counters also appear in the Counters
table.
Connectors have no equivalent at present, so they cannot report facts that
belong to the Connector itself, such as how many items a setup or migration
step has completed, or how far behind an external system the connector is.
h2. Proposed Solution
Let a Connector record Counters and Gauges directly, using the same naming and
attribute model that Processors use. The metrics are reported through the
existing ComponentMetricReporter, so any reporter that already handles
Processor metrics receives Connector metrics with no changes.
A Connector has no ProcessSession and no commit, so there is no CommitTiming
argument. Every value is recorded as soon as the method is called.
h2. NiFi API Changes
Two new default methods are added to ConnectorInitializationContext. Both
default to doing nothing, so existing implementations and callers are
unaffected.
{code:java}
/**
* Adjusts the named Counter by the given delta, registering it if needed.
*/
default void adjustCounter(String name, long delta, Map<String, String>
attributes) { }
/**
* Records a point-in-time measurement for the named Gauge, registering it if
needed, and associates the given attributes with the Gauge.
*/
default void recordGauge(String name, double value, Map<String, String>
attributes) { }
{code}
h2. Framework Changes
* StandardConnectorInitializationContext implements both methods. It builds
the component context and passes the values to the ComponentMetricReporter.
* Counter adjustments are also written to the CounterRepository under the
Connector's context, in the same way as for Processors.
* The Connector mock test harness already records metrics by component
identifier, so Connector tests can assert on the new metrics with no new test
API.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)