use of io.confluent.ksql.metrics.TopicSensors.SensorMetric in project ksql by confluentinc.
the class ConsumerCollector method buildSensors.
private List<SensorMetric<ConsumerRecord<Object, Object>>> buildSensors(final String key) {
final List<SensorMetric<ConsumerRecord<Object, Object>>> sensors = new ArrayList<>();
addSensor(key, CONSUMER_MESSAGES_PER_SEC, new Rate(), sensors, false);
addSensor(key, CONSUMER_TOTAL_MESSAGES, new CumulativeSum(), sensors, false);
addSensor(key, CONSUMER_TOTAL_BYTES, new CumulativeSum(), sensors, false, (r) -> {
if (r == null) {
return 0.0;
} else {
return ((double) r.serializedValueSize() + r.serializedKeySize());
}
});
return sensors;
}
use of io.confluent.ksql.metrics.TopicSensors.SensorMetric in project ksql by confluentinc.
the class ProducerCollector method buildSensors.
private List<SensorMetric<ProducerRecord<Object, Object>>> buildSensors(final String key) {
final List<SensorMetric<ProducerRecord<Object, Object>>> sensors = new ArrayList<>();
// activity in a reliable way
synchronized (metrics) {
addSensor(key, PRODUCER_MESSAGES_PER_SEC, new Rate(), sensors);
addSensor(key, PRODUCER_TOTAL_MESSAGES, new CumulativeSum(), sensors);
}
return sensors;
}
use of io.confluent.ksql.metrics.TopicSensors.SensorMetric in project ksql by confluentinc.
the class StreamsErrorCollector method buildSensor.
private SensorMetric<Object> buildSensor(final String key, final String metricNameString, final MeasurableStat stat, final Function<Object, Double> recordValue) {
final String name = "sec-" + key + "-" + metricNameString + "-" + id;
final MetricName metricName = new MetricName(metricNameString, "consumer-metrics", "consumer-" + name, ImmutableMap.of("key", key, "id", id));
final Sensor sensor = metrics.sensor(name);
sensor.add(metricName, stat);
final KafkaMetric metric = metrics.metrics().get(metricName);
return new TopicSensors.SensorMetric<Object>(sensor, metric, time, true) {
void record(final Object o) {
sensor.record(recordValue.apply(o));
super.record(o);
}
};
}
Aggregations