Search in sources :

Example 16 with StreamsMetrics

use of org.apache.kafka.streams.StreamsMetrics in project kafka by apache.

the class MeteredSegmentedBytesStoreTest method setUp.

@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
    final Metrics metrics = new Metrics();
    final StreamsMetrics streamsMetrics = new StreamsMetrics() {

        @Override
        public Map<MetricName, ? extends Metric> metrics() {
            return Collections.unmodifiableMap(metrics.metrics());
        }

        @Override
        public Sensor addLatencyAndThroughputSensor(String scopeName, String entityName, String operationName, Sensor.RecordingLevel recordLevel, String... tags) {
            return metrics.sensor(operationName);
        }

        @Override
        public void recordLatency(final Sensor sensor, final long startNs, final long endNs) {
            latencyRecorded.add(sensor.name());
        }

        @Override
        public Sensor addThroughputSensor(String scopeName, String entityName, String operationName, Sensor.RecordingLevel recordLevel, String... tags) {
            return metrics.sensor(operationName);
        }

        @Override
        public void recordThroughput(Sensor sensor, long value) {
            throughputRecorded.add(sensor.name());
        }

        @Override
        public void removeSensor(Sensor sensor) {
            metrics.removeSensor(sensor.name());
        }

        @Override
        public Sensor addSensor(String name, Sensor.RecordingLevel recordLevel) {
            return metrics.sensor(name);
        }

        @Override
        public Sensor addSensor(String name, Sensor.RecordingLevel recordLevel, Sensor... parents) {
            return metrics.sensor(name);
        }
    };
    final MockProcessorContext context = new MockProcessorContext(TestUtils.tempDirectory(), Serdes.String(), Serdes.Long(), new NoOpRecordCollector(), new ThreadCache("testCache", 0, streamsMetrics)) {

        @Override
        public StreamsMetrics metrics() {
            return streamsMetrics;
        }
    };
    store.init(context, store);
}
Also used : MetricName(org.apache.kafka.common.MetricName) Metrics(org.apache.kafka.common.metrics.Metrics) StreamsMetrics(org.apache.kafka.streams.StreamsMetrics) NoOpRecordCollector(org.apache.kafka.test.NoOpRecordCollector) StreamsMetrics(org.apache.kafka.streams.StreamsMetrics) MockProcessorContext(org.apache.kafka.test.MockProcessorContext) Sensor(org.apache.kafka.common.metrics.Sensor) Before(org.junit.Before)

Example 17 with StreamsMetrics

use of org.apache.kafka.streams.StreamsMetrics in project kafka by apache.

the class RocksDBWindowStoreSupplierTest method shouldHaveMeteredStoreWhenLogged.

@SuppressWarnings("unchecked")
@Test
public void shouldHaveMeteredStoreWhenLogged() throws Exception {
    store = createStore(true, false);
    store.init(context, store);
    final StreamsMetrics metrics = context.metrics();
    assertFalse(metrics.metrics().isEmpty());
}
Also used : MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) StreamsMetrics(org.apache.kafka.streams.StreamsMetrics) Test(org.junit.Test)

Example 18 with StreamsMetrics

use of org.apache.kafka.streams.StreamsMetrics in project kafka by apache.

the class RocksDBWindowStoreSupplierTest method shouldHaveMeteredStoreWhenCached.

@SuppressWarnings("unchecked")
@Test
public void shouldHaveMeteredStoreWhenCached() throws Exception {
    store = createStore(false, true);
    store.init(context, store);
    final StreamsMetrics metrics = context.metrics();
    assertFalse(metrics.metrics().isEmpty());
}
Also used : MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) StreamsMetrics(org.apache.kafka.streams.StreamsMetrics) Test(org.junit.Test)

Example 19 with StreamsMetrics

use of org.apache.kafka.streams.StreamsMetrics in project apache-kafka-on-k8s by banzaicloud.

the class RocksDBSessionStoreSupplierTest method shouldHaveMeteredStoreWhenLogged.

@Test
public void shouldHaveMeteredStoreWhenLogged() {
    store = createStore(true, false);
    store.init(context, store);
    final StreamsMetrics metrics = context.metrics();
    assertFalse(metrics.metrics().isEmpty());
}
Also used : MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) StreamsMetrics(org.apache.kafka.streams.StreamsMetrics) Test(org.junit.Test)

Example 20 with StreamsMetrics

use of org.apache.kafka.streams.StreamsMetrics in project apache-kafka-on-k8s by banzaicloud.

the class RocksDBWindowStoreSupplierTest method shouldHaveMeteredStoreWhenLogged.

@Test
public void shouldHaveMeteredStoreWhenLogged() {
    store = createStore(true, false, 3);
    store.init(context, store);
    final StreamsMetrics metrics = context.metrics();
    assertFalse(metrics.metrics().isEmpty());
}
Also used : MockStreamsMetrics(org.apache.kafka.streams.processor.internals.MockStreamsMetrics) StreamsMetrics(org.apache.kafka.streams.StreamsMetrics) Test(org.junit.Test)

Aggregations

StreamsMetrics (org.apache.kafka.streams.StreamsMetrics)21 Test (org.junit.Test)19 MockStreamsMetrics (org.apache.kafka.streams.processor.internals.MockStreamsMetrics)16 Metrics (org.apache.kafka.common.metrics.Metrics)5 NoOpRecordCollector (org.apache.kafka.test.NoOpRecordCollector)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 MetricName (org.apache.kafka.common.MetricName)2 Sensor (org.apache.kafka.common.metrics.Sensor)2 LogContext (org.apache.kafka.common.utils.LogContext)2 Before (org.junit.Before)2 File (java.io.File)1 PartitionInfo (org.apache.kafka.common.PartitionInfo)1 TopicPartition (org.apache.kafka.common.TopicPartition)1 MockTime (org.apache.kafka.common.utils.MockTime)1 StreamsConfig (org.apache.kafka.streams.StreamsConfig)1 ProductionExceptionHandler (org.apache.kafka.streams.errors.ProductionExceptionHandler)1 ProcessorContext (org.apache.kafka.streams.processor.ProcessorContext)1 StateStore (org.apache.kafka.streams.processor.StateStore)1 TaskId (org.apache.kafka.streams.processor.TaskId)1 InMemoryKeyValueStore (org.apache.kafka.streams.state.internals.InMemoryKeyValueStore)1