Search in sources :

Example 1 with WavefrontHistogram

use of com.wavefront.internal_reporter_java.io.dropwizard.metrics5.WavefrontHistogram in project java by wavefrontHQ.

the class CustomTracingPortUnificationHandlerTest method reportsCorrectDuration.

@Test
public void reportsCorrectDuration() {
    WavefrontInternalReporter reporter = EasyMock.niceMock(WavefrontInternalReporter.class);
    expect(reporter.newDeltaCounter(anyObject())).andReturn(new DeltaCounter()).anyTimes();
    WavefrontHistogram histogram = EasyMock.niceMock(WavefrontHistogram.class);
    expect(reporter.newWavefrontHistogram(anyObject(), anyObject())).andReturn(histogram);
    Capture<Long> duration = newCapture();
    histogram.update(captureLong(duration));
    expectLastCall();
    ReportableEntityHandler<Span, String> handler = MockReportableEntityHandlerFactory.getMockTraceHandler();
    CustomTracingPortUnificationHandler subject = new CustomTracingPortUnificationHandler(null, null, null, null, null, null, handler, null, null, null, null, null, reporter, null, null, null);
    replay(reporter, histogram);
    Span span = getSpan();
    // milliseconds
    span.setDuration(1000);
    subject.report(span);
    verify(reporter, histogram);
    long value = duration.getValue();
    // microseconds
    assertEquals(1000000, value);
}
Also used : WavefrontInternalReporter(com.wavefront.internal.reporter.WavefrontInternalReporter) EasyMock.captureLong(org.easymock.EasyMock.captureLong) WavefrontHistogram(com.wavefront.internal_reporter_java.io.dropwizard.metrics5.WavefrontHistogram) Span(wavefront.report.Span) DeltaCounter(com.wavefront.internal_reporter_java.io.dropwizard.metrics5.DeltaCounter) Test(org.junit.Test)

Aggregations

WavefrontInternalReporter (com.wavefront.internal.reporter.WavefrontInternalReporter)1 DeltaCounter (com.wavefront.internal_reporter_java.io.dropwizard.metrics5.DeltaCounter)1 WavefrontHistogram (com.wavefront.internal_reporter_java.io.dropwizard.metrics5.WavefrontHistogram)1 EasyMock.captureLong (org.easymock.EasyMock.captureLong)1 Test (org.junit.Test)1 Span (wavefront.report.Span)1