Search in sources :

Example 1 with RecordingLevel

use of org.apache.kafka.common.metrics.Sensor.RecordingLevel in project kafka by apache.

the class StreamsMetricsImplTest method shouldGetExistingClientLevelSensor.

@Test
public void shouldGetExistingClientLevelSensor() {
    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.clientLevelSensor(SENSOR_NAME_1, recordingLevel);
    verify(metrics);
    assertThat(actualSensor, is(equalToObject(sensor)));
}
Also used : RecordingLevel(org.apache.kafka.common.metrics.Sensor.RecordingLevel) Metrics(org.apache.kafka.common.metrics.Metrics) Sensor(org.apache.kafka.common.metrics.Sensor) StreamsMetricsImpl.addInvocationRateAndCountToSensor(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.addInvocationRateAndCountToSensor) StreamsMetricsImpl.addAvgAndMaxLatencyToSensor(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.addAvgAndMaxLatencyToSensor) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with RecordingLevel

use of org.apache.kafka.common.metrics.Sensor.RecordingLevel in project kafka by apache.

the class StreamsMetricsImplTest method shouldGetNewStoreLevelSensorIfNoneExists.

@Test
public void shouldGetNewStoreLevelSensorIfNoneExists() {
    final Metrics metrics = mock(Metrics.class);
    final RecordingLevel recordingLevel = RecordingLevel.INFO;
    final Capture<String> sensorKeys = setupGetNewSensorTest(metrics, recordingLevel);
    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)));
    assertThat(sensorKeys.getValues().get(0), is(sensorKeys.getValues().get(1)));
}
Also used : RecordingLevel(org.apache.kafka.common.metrics.Sensor.RecordingLevel) Metrics(org.apache.kafka.common.metrics.Metrics) EasyMock.anyString(org.easymock.EasyMock.anyString) Sensor(org.apache.kafka.common.metrics.Sensor) StreamsMetricsImpl.addInvocationRateAndCountToSensor(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.addInvocationRateAndCountToSensor) StreamsMetricsImpl.addAvgAndMaxLatencyToSensor(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.addAvgAndMaxLatencyToSensor) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with RecordingLevel

use of org.apache.kafka.common.metrics.Sensor.RecordingLevel in project kafka by apache.

the class StreamsMetricsImplTest method shouldGetExistingTaskLevelSensor.

@Test
public void shouldGetExistingTaskLevelSensor() {
    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.taskLevelSensor(THREAD_ID1, TASK_ID1, SENSOR_NAME_1, recordingLevel);
    verify(metrics);
    assertThat(actualSensor, is(equalToObject(sensor)));
}
Also used : RecordingLevel(org.apache.kafka.common.metrics.Sensor.RecordingLevel) Metrics(org.apache.kafka.common.metrics.Metrics) Sensor(org.apache.kafka.common.metrics.Sensor) StreamsMetricsImpl.addInvocationRateAndCountToSensor(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.addInvocationRateAndCountToSensor) StreamsMetricsImpl.addAvgAndMaxLatencyToSensor(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.addAvgAndMaxLatencyToSensor) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with RecordingLevel

use of org.apache.kafka.common.metrics.Sensor.RecordingLevel in project kafka by apache.

the class StreamsMetricsImplTest method shouldGetNewNodeLevelSensor.

@Test
public void shouldGetNewNodeLevelSensor() {
    final Metrics metrics = mock(Metrics.class);
    final RecordingLevel recordingLevel = RecordingLevel.INFO;
    final String processorNodeName = "processorNodeName";
    setupGetNewSensorTest(metrics, recordingLevel);
    final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, CLIENT_ID, VERSION, time);
    final Sensor actualSensor = streamsMetrics.nodeLevelSensor(THREAD_ID1, TASK_ID1, processorNodeName, SENSOR_NAME_1, recordingLevel);
    verify(metrics);
    assertThat(actualSensor, is(equalToObject(sensor)));
}
Also used : RecordingLevel(org.apache.kafka.common.metrics.Sensor.RecordingLevel) Metrics(org.apache.kafka.common.metrics.Metrics) EasyMock.anyString(org.easymock.EasyMock.anyString) Sensor(org.apache.kafka.common.metrics.Sensor) StreamsMetricsImpl.addInvocationRateAndCountToSensor(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.addInvocationRateAndCountToSensor) StreamsMetricsImpl.addAvgAndMaxLatencyToSensor(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.addAvgAndMaxLatencyToSensor) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with RecordingLevel

use of org.apache.kafka.common.metrics.Sensor.RecordingLevel in project kafka by apache.

the class StreamsMetricsImplTest method shouldGetNewCacheLevelSensor.

@Test
public void shouldGetNewCacheLevelSensor() {
    final Metrics metrics = mock(Metrics.class);
    final RecordingLevel recordingLevel = RecordingLevel.INFO;
    final String processorCacheName = "processorNodeName";
    setupGetNewSensorTest(metrics, recordingLevel);
    final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, CLIENT_ID, VERSION, time);
    final Sensor actualSensor = streamsMetrics.cacheLevelSensor(THREAD_ID1, TASK_ID1, processorCacheName, SENSOR_NAME_1, recordingLevel);
    verify(metrics);
    assertThat(actualSensor, is(equalToObject(sensor)));
}
Also used : RecordingLevel(org.apache.kafka.common.metrics.Sensor.RecordingLevel) Metrics(org.apache.kafka.common.metrics.Metrics) EasyMock.anyString(org.easymock.EasyMock.anyString) Sensor(org.apache.kafka.common.metrics.Sensor) StreamsMetricsImpl.addInvocationRateAndCountToSensor(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.addInvocationRateAndCountToSensor) StreamsMetricsImpl.addAvgAndMaxLatencyToSensor(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.addAvgAndMaxLatencyToSensor) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Metrics (org.apache.kafka.common.metrics.Metrics)16 RecordingLevel (org.apache.kafka.common.metrics.Sensor.RecordingLevel)16 Sensor (org.apache.kafka.common.metrics.Sensor)15 Test (org.junit.Test)14 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)14 StreamsMetricsImpl.addAvgAndMaxLatencyToSensor (org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.addAvgAndMaxLatencyToSensor)13 StreamsMetricsImpl.addInvocationRateAndCountToSensor (org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.addInvocationRateAndCountToSensor)13 EasyMock.anyString (org.easymock.EasyMock.anyString)7 MetricConfig (org.apache.kafka.common.metrics.MetricConfig)4 Collections (java.util.Collections)3 Map (java.util.Map)3 TimeUnit (java.util.concurrent.TimeUnit)3 MetricName (org.apache.kafka.common.MetricName)3 Gauge (org.apache.kafka.common.metrics.Gauge)3 Rate (org.apache.kafka.common.metrics.stats.Rate)3 Time (org.apache.kafka.common.utils.Time)3 Deque (java.util.Deque)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedList (java.util.LinkedList)2