Search in sources :

Example 1 with CLIENT_LEVEL_GROUP

use of org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.CLIENT_LEVEL_GROUP in project kafka by apache.

the class StreamsMetricsImplTest method shouldAddClientLevelMutableMetric.

@Test
public void shouldAddClientLevelMutableMetric() {
    final Metrics metrics = mock(Metrics.class);
    final RecordingLevel recordingLevel = RecordingLevel.INFO;
    final MetricConfig metricConfig = new MetricConfig().recordLevel(recordingLevel);
    final Gauge<String> valueProvider = (config, now) -> "mutable-value";
    expect(metrics.metricName(METRIC_NAME1, CLIENT_LEVEL_GROUP, DESCRIPTION1, clientLevelTags)).andReturn(metricName1);
    metrics.addMetric(EasyMock.eq(metricName1), eqMetricConfig(metricConfig), eq(valueProvider));
    replay(metrics);
    final StreamsMetricsImpl streamsMetrics = new StreamsMetricsImpl(metrics, CLIENT_ID, VERSION, time);
    streamsMetrics.addClientLevelMutableMetric(METRIC_NAME1, DESCRIPTION1, recordingLevel, valueProvider);
    verify(metrics);
}
Also used : RecordingLevel(org.apache.kafka.common.metrics.Sensor.RecordingLevel) MetricConfig(org.apache.kafka.common.metrics.MetricConfig) CoreMatchers.is(org.hamcrest.CoreMatchers.is) RecordingLevel(org.apache.kafka.common.metrics.Sensor.RecordingLevel) MockTime(org.apache.kafka.common.utils.MockTime) Arrays(java.util.Arrays) Rate(org.apache.kafka.common.metrics.stats.Rate) EasyMock.capture(org.easymock.EasyMock.capture) THREAD_LEVEL_GROUP(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.THREAD_LEVEL_GROUP) ImmutableMetricValue(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.ImmutableMetricValue) RATE_SUFFIX(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.RATE_SUFFIX) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) Utils.mkMap(org.apache.kafka.common.utils.Utils.mkMap) IArgumentMatcher(org.easymock.IArgumentMatcher) ROLLUP_VALUE(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.ROLLUP_VALUE) Duration(java.time.Duration) Map(java.util.Map) AVG_SUFFIX(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.AVG_SUFFIX) MetricName(org.apache.kafka.common.MetricName) EasyMock.eq(org.easymock.EasyMock.eq) Sensor(org.apache.kafka.common.metrics.Sensor) TOTAL_SUFFIX(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.TOTAL_SUFFIX) Time(org.apache.kafka.common.utils.Time) EasyMock.newCapture(org.easymock.EasyMock.newCapture) MetricConfig(org.apache.kafka.common.metrics.MetricConfig) EasyMock.resetToDefault(org.easymock.EasyMock.resetToDefault) List(java.util.List) Metrics(org.apache.kafka.common.metrics.Metrics) Utils.mkEntry(org.apache.kafka.common.utils.Utils.mkEntry) Matchers.equalTo(org.hamcrest.Matchers.equalTo) KafkaMetric(org.apache.kafka.common.metrics.KafkaMetric) CoreMatchers.equalToObject(org.hamcrest.CoreMatchers.equalToObject) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) CLIENT_LEVEL_GROUP(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.CLIENT_LEVEL_GROUP) PowerMock.createMock(org.powermock.api.easymock.PowerMock.createMock) StreamsConfig(org.apache.kafka.streams.StreamsConfig) Assert.assertThrows(org.junit.Assert.assertThrows) RunWith(org.junit.runner.RunWith) CoreMatchers.not(org.hamcrest.CoreMatchers.not) CLIENT_ID_TAG(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.CLIENT_ID_TAG) EasyMock.mock(org.easymock.EasyMock.mock) 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) EasyMock.replay(org.easymock.EasyMock.replay) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) PowerMockRunner(org.powermock.modules.junit4.PowerMockRunner) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) EasyMock.anyObject(org.easymock.EasyMock.anyObject) Capture(org.easymock.Capture) EasyMock.anyString(org.easymock.EasyMock.anyString) MAX_SUFFIX(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.MAX_SUFFIX) EasyMock.niceMock(org.easymock.EasyMock.niceMock) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) LATENCY_SUFFIX(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.LATENCY_SUFFIX) Version(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.Version) EasyMock(org.easymock.EasyMock) EasyMock.expect(org.easymock.EasyMock.expect) TimeUnit(java.util.concurrent.TimeUnit) STATE_STORE_LEVEL_GROUP(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.STATE_STORE_LEVEL_GROUP) CaptureType(org.easymock.CaptureType) Gauge(org.apache.kafka.common.metrics.Gauge) StreamsTestUtils(org.apache.kafka.test.StreamsTestUtils) EasyMock.verify(org.easymock.EasyMock.verify) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) PROCESSOR_NODE_LEVEL_GROUP(org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.PROCESSOR_NODE_LEVEL_GROUP) Metrics(org.apache.kafka.common.metrics.Metrics) EasyMock.anyString(org.easymock.EasyMock.anyString) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Duration (java.time.Duration)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 TimeUnit (java.util.concurrent.TimeUnit)1 MetricName (org.apache.kafka.common.MetricName)1 Gauge (org.apache.kafka.common.metrics.Gauge)1 KafkaMetric (org.apache.kafka.common.metrics.KafkaMetric)1 MetricConfig (org.apache.kafka.common.metrics.MetricConfig)1 Metrics (org.apache.kafka.common.metrics.Metrics)1 Sensor (org.apache.kafka.common.metrics.Sensor)1 RecordingLevel (org.apache.kafka.common.metrics.Sensor.RecordingLevel)1 Rate (org.apache.kafka.common.metrics.stats.Rate)1 MockTime (org.apache.kafka.common.utils.MockTime)1 Time (org.apache.kafka.common.utils.Time)1 Utils.mkEntry (org.apache.kafka.common.utils.Utils.mkEntry)1 Utils.mkMap (org.apache.kafka.common.utils.Utils.mkMap)1 StreamsConfig (org.apache.kafka.streams.StreamsConfig)1 AVG_SUFFIX (org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl.AVG_SUFFIX)1