public abstract static class KafkaMetrics.KafkaMetricsImpl extends java.lang.Object implements KafkaMetrics
Expected usage: A number of threads record metrics in an instance of this class with the
member methods. Afterwards, a single thread should call updateStreamingInsertsMetrics
which will export all counters metrics and RPC latency distribution metrics to the underlying
perWorkerMetrics
container. Afterwards, metrics should not be written/read from this
object.
KafkaMetrics.KafkaMetricsImpl, KafkaMetrics.NoOpKafkaMetrics
Constructor and Description |
---|
KafkaMetricsImpl() |
Modifier and Type | Method and Description |
---|---|
static KafkaMetrics.KafkaMetricsImpl |
create() |
void |
flushBufferedMetrics()
Export all metrics recorded in this instance to the underlying
perWorkerMetrics
containers. |
void |
updateBacklogBytes(java.lang.String topicName,
int partitionId,
long backlog)
This is for tracking backlog bytes to be added to the Metric Container at a later time.
|
void |
updateSuccessfulRpcMetrics(java.lang.String topic,
java.time.Duration elapsedTime)
Record the rpc status and latency of a successful Kafka poll RPC call.
|
public static KafkaMetrics.KafkaMetricsImpl create()
public void updateSuccessfulRpcMetrics(java.lang.String topic, java.time.Duration elapsedTime)
TODO(naireenhussain): It's possible that `isWritable().get()` is called before it's set to false in another thread, allowing an extraneous measurement to slip in, so perTopicRpcLatencies() isn't necessarily thread safe. One way to address this would be to add synchronized blocks to ensure that there is only one thread ever reading/modifying the perTopicRpcLatencies() map.
updateSuccessfulRpcMetrics
in interface KafkaMetrics
public void updateBacklogBytes(java.lang.String topicName, int partitionId, long backlog)
updateBacklogBytes
in interface KafkaMetrics
topicName
- topicNamepartitionId
- partitionIdbacklog
- backlog for the specific partitionID of topicNamepublic void flushBufferedMetrics()
perWorkerMetrics
containers. This function will only report metrics once per instance. Subsequent calls to
this function will no-op.flushBufferedMetrics
in interface KafkaMetrics