use of org.apache.kafka.common.metrics.Sensor.RecordingLevel in project kafka by apache.
the class StreamsMetricsImplTest method shouldGetExistingStoreLevelSensor.
@Test
public void shouldGetExistingStoreLevelSensor() {
final Metrics metrics = mock(Metrics.class);
final RecordingLevel recordingLevel = RecordingLevel.INFO;
setupGetExistingSensorTest(metrics);
final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, CLIENT_ID, VERSION, time);
final Sensor actualSensor = streamsMetrics.storeLevelSensor(TASK_ID1, STORE_NAME1, SENSOR_NAME_1, recordingLevel);
verify(metrics);
assertThat(actualSensor, is(equalToObject(sensor)));
}
use of org.apache.kafka.common.metrics.Sensor.RecordingLevel in project kafka by apache.
the class StreamsMetricsImplTest method shouldGetNewClientLevelSensor.
@Test
public void shouldGetNewClientLevelSensor() {
final Metrics metrics = mock(Metrics.class);
final RecordingLevel recordingLevel = RecordingLevel.INFO;
setupGetNewSensorTest(metrics, recordingLevel);
final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, CLIENT_ID, VERSION, time);
final Sensor actualSensor = streamsMetrics.clientLevelSensor(SENSOR_NAME_1, recordingLevel);
verify(metrics);
assertThat(actualSensor, is(equalToObject(sensor)));
}
use of org.apache.kafka.common.metrics.Sensor.RecordingLevel in project kafka by apache.
the class StreamsMetricsImpl method getSensors.
private Sensor getSensors(final Map<String, Deque<String>> sensors, final String sensorName, final String key, final RecordingLevel recordingLevel, final Sensor... parents) {
final String fullSensorName = key + SENSOR_NAME_DELIMITER + sensorName;
final Sensor sensor = metrics.getSensor(fullSensorName);
if (sensor == null) {
sensors.computeIfAbsent(key, ignored -> new LinkedList<>()).push(fullSensorName);
return metrics.sensor(fullSensorName, recordingLevel, parents);
}
return sensor;
}
use of org.apache.kafka.common.metrics.Sensor.RecordingLevel in project kafka by apache.
the class StreamsMetricsImpl method addStoreLevelMutableMetric.
public <T> void addStoreLevelMutableMetric(final String taskId, final String metricsScope, final String storeName, final String name, final String description, final RecordingLevel recordingLevel, final Gauge<T> valueProvider) {
final MetricName metricName = metrics.metricName(name, STATE_STORE_LEVEL_GROUP, description, storeLevelTagMap(taskId, metricsScope, storeName));
if (metrics.metric(metricName) == null) {
final MetricConfig metricConfig = new MetricConfig().recordLevel(recordingLevel);
final String key = storeSensorPrefix(Thread.currentThread().getName(), taskId, storeName);
metrics.addMetric(metricName, metricConfig, valueProvider);
storeLevelMetrics.computeIfAbsent(key, ignored -> new LinkedList<>()).push(metricName);
}
}
use of org.apache.kafka.common.metrics.Sensor.RecordingLevel in project kafka by apache.
the class StreamsMetricsImplTest method shouldGetNewTaskLevelSensor.
@Test
public void shouldGetNewTaskLevelSensor() {
final Metrics metrics = mock(Metrics.class);
final RecordingLevel recordingLevel = RecordingLevel.INFO;
setupGetNewSensorTest(metrics, recordingLevel);
final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, CLIENT_ID, VERSION, time);
final Sensor actualSensor = streamsMetrics.taskLevelSensor(THREAD_ID1, TASK_ID1, SENSOR_NAME_1, recordingLevel);
verify(metrics);
assertThat(actualSensor, is(equalToObject(sensor)));
}
Aggregations