use of org.eclipse.microprofile.metrics.Histogram in project Payara by payara.
the class BulkheadMetricTckTest method bulkheadMetricHistogramTest.
/**
* Scenario is equivalent to the TCK test of same name but not 100% identical
*/
@Test(timeout = 3000)
public void bulkheadMetricHistogramTest() {
callMethodWithNewThreadAndWaitFor(commonWaiter);
callMethodWithNewThreadAndWaitFor(commonWaiter);
waitUntilPermitsAquired(2, 0);
assertFurtherThreadThrowsBulkheadException(1);
waitSome(100);
commonWaiter.complete(null);
waitUntilPermitsAquired(0, 0);
Histogram executionTimes = registry.getHistogram(new MetricID("ft.bulkhead.runningDuration", new Tag("method", "fish.payara.microprofile.faulttolerance.policy.BulkheadMetricTckTest.bulkheadMetricHistogramTest_Method")));
Snapshot snap = executionTimes.getSnapshot();
assertNotNull(executionTimes);
assertEquals(2, executionTimes.getCount());
assertApproxMillis(100, Math.round(snap.getMedian()));
assertApproxMillis(100, Math.round(snap.getMean()));
// Now let's put some quick results through the bulkhead
callMethodDirectly(null);
callMethodDirectly(null);
assertEquals(4, executionTimes.getCount());
snap = executionTimes.getSnapshot();
assertApproxMillis(50, Math.round(snap.getMean()));
}
use of org.eclipse.microprofile.metrics.Histogram in project Payara by payara.
the class MetricRegistryImplTest method registerByMetadataAllowsToReuseAsLongAsMetadataIsSame.
@Test
public void registerByMetadataAllowsToReuseAsLongAsMetadataIsSame() {
Histogram h1 = new HistogramImpl();
assertExistingMetadataIsUsed(name -> registry.register(withName(name), h1), name -> registry.register(withName(name), new HistogramImpl()));
assertSame(h1, registry.getHistograms().values().iterator().next());
}
use of org.eclipse.microprofile.metrics.Histogram in project Payara by payara.
the class OpenMetricsExporterTest method quantilesAreAppendedOtherTags.
@Test
public void quantilesAreAppendedOtherTags() {
Histogram histogram = mock(Histogram.class);
Snapshot snapshot = mock(Snapshot.class);
when(histogram.getSnapshot()).thenReturn(snapshot);
MetricID metricID = new MetricID("test6", new Tag("custom", "tag-value"));
Metadata metadata = Metadata.builder().withName(metricID.getName()).withUnit(MetricUnits.MILLISECONDS).build();
exporter.export(metricID, histogram, metadata);
String actualOutput = actual.getBuffer().toString();
assertTrue(actualOutput.contains("application_test6_seconds{custom=\"tag-value\",quantile=\"0.5\"} 0"));
}
use of org.eclipse.microprofile.metrics.Histogram in project Payara by payara.
the class JsonExporterGetTest method exportHistogram.
@Test
public void exportHistogram() {
Histogram histogram = mock(Histogram.class);
when(histogram.getCount()).thenReturn(2L);
when(histogram.getSum()).thenReturn(42L);
Snapshot snapshot = mock(Snapshot.class);
when(histogram.getSnapshot()).thenReturn(snapshot);
when(snapshot.getMin()).thenReturn(-1624L);
when(snapshot.getMax()).thenReturn(26L);
when(snapshot.getMean()).thenReturn(-799.0d);
when(snapshot.getStdDev()).thenReturn(825d);
when(snapshot.getMedian()).thenReturn(26d);
when(snapshot.get75thPercentile()).thenReturn(26d);
when(snapshot.get95thPercentile()).thenReturn(26d);
when(snapshot.get98thPercentile()).thenReturn(26d);
when(snapshot.get99thPercentile()).thenReturn(26d);
when(snapshot.get999thPercentile()).thenReturn(26d);
// example uses same values for both histograms so we can get away with just one
// but conceptually those should be two different histogram instances
export(new MetricID("daily_value_changes"), histogram);
export(new MetricID("daily_value_changes", new Tag("servlet", "two")), histogram);
assertOutputEqualsFile("Histogram.json");
}
use of org.eclipse.microprofile.metrics.Histogram in project Payara by payara.
the class OpenMetricsExporterTest method exportHistogram.
@Test
public void exportHistogram() {
Histogram histogram = mock(Histogram.class);
when(histogram.getCount()).thenReturn(2037L);
when(histogram.getSum()).thenReturn(45678L);
Snapshot snapshot = mock(Snapshot.class);
when(histogram.getSnapshot()).thenReturn(snapshot);
when(snapshot.getMin()).thenReturn(180L);
when(snapshot.getMax()).thenReturn(31716L);
when(snapshot.getMean()).thenReturn(4738.231d);
when(snapshot.getStdDev()).thenReturn(1054.7343037063602d);
when(snapshot.getMedian()).thenReturn(4201d);
when(snapshot.get75thPercentile()).thenReturn(6175d);
when(snapshot.get95thPercentile()).thenReturn(13560d);
when(snapshot.get98thPercentile()).thenReturn(29643d);
when(snapshot.get99thPercentile()).thenReturn(31716d);
when(snapshot.get999thPercentile()).thenReturn(31716d);
MetricID metricID = new MetricID("file_sizes");
Metadata metadata = Metadata.builder().withName(metricID.getName()).withDescription("Users file size").withUnit(MetricUnits.BYTES).build();
assertOutputEqualsFile("Histogram.txt", metricID, histogram, metadata);
}
Aggregations