Search in sources :

Example 16 with RecordingLevel

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

the class StreamsMetricsImplTest method shouldAddClientLevelImmutableMetric.

@Test
public void shouldAddClientLevelImmutableMetric() {
    final Metrics metrics = mock(Metrics.class);
    final RecordingLevel recordingLevel = RecordingLevel.INFO;
    final MetricConfig metricConfig = new MetricConfig().recordLevel(recordingLevel);
    final String value = "immutable-value";
    final ImmutableMetricValue immutableValue = new ImmutableMetricValue<>(value);
    expect(metrics.metricName(METRIC_NAME1, CLIENT_LEVEL_GROUP, DESCRIPTION1, clientLevelTags)).andReturn(metricName1);
    metrics.addMetric(eq(metricName1), eqMetricConfig(metricConfig), eq(immutableValue));
    replay(metrics);
    final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, CLIENT_ID, VERSION, time);
    streamsMetrics.addClientLevelImmutableMetric(METRIC_NAME1, DESCRIPTION1, recordingLevel, value);
    verify(metrics);
}
Also used : RecordingLevel(org.apache.kafka.common.metrics.Sensor.RecordingLevel) MetricConfig(org.apache.kafka.common.metrics.MetricConfig) Metrics(org.apache.kafka.common.metrics.Metrics) EasyMock.anyString(org.easymock.EasyMock.anyString) ImmutableMetricValue(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.ImmutableMetricValue) 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