Search in sources :

Example 1 with StreamThreadTotalBlockedTime

use of org.apache.kafka.streams.processor.internals.StreamThreadTotalBlockedTime in project kafka by apache.

the class ThreadMetricsTest method shouldAddTotalBlockedTimeMetric.

@Test
public void shouldAddTotalBlockedTimeMetric() {
    // Given:
    final double startTime = 123.45;
    final StreamThreadTotalBlockedTime blockedTime = mock(StreamThreadTotalBlockedTime.class);
    when(blockedTime.compute()).thenReturn(startTime);
    // When:
    ThreadMetrics.addThreadBlockedTimeMetric("burger", blockedTime, streamsMetrics);
    // Then:
    final ArgumentCaptor<Gauge<Double>> captor = gaugeCaptor();
    verify(streamsMetrics).addThreadLevelMutableMetric(eq("blocked-time-ns-total"), eq("The total time the thread spent blocked on kafka in nanoseconds"), eq("burger"), captor.capture());
    assertThat(captor.getValue().value(null, 678L), is(startTime));
}
Also used : StreamThreadTotalBlockedTime(org.apache.kafka.streams.processor.internals.StreamThreadTotalBlockedTime) Gauge(org.apache.kafka.common.metrics.Gauge) Test(org.junit.Test)

Aggregations

Gauge (org.apache.kafka.common.metrics.Gauge)1 StreamThreadTotalBlockedTime (org.apache.kafka.streams.processor.internals.StreamThreadTotalBlockedTime)1 Test (org.junit.Test)1