use of org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl in project ignite by apache.
the class OpenCensusMetricExporterSpiTest method testHistogram.
/**
*/
@Test
public void testHistogram() throws Exception {
String registryName = "test_registry";
String histogramName = "test_histogram";
String histogramDesc = "Test histogram description.";
long[] bounds = new long[] { 10, 100 };
long[] testValues = new long[] { 5, 50, 50, 500, 500, 500 };
String[] expectedValuesPtrn = new String[] { "test_registry_test_histogram_0_10.* 1", "test_registry_test_histogram_10_100.* 2", "test_registry_test_histogram_100_inf.* 3" };
HistogramMetricImpl histogramMetric = ignite.context().metric().registry(registryName).histogram(histogramName, bounds, histogramDesc);
for (long value : testValues) histogramMetric.value(value);
assertTrue("Histogram metrics should be exported via http", checkHttpMetrics(expectedValuesPtrn));
bounds = new long[] { 50 };
histogramMetric.reset(bounds);
for (long value : testValues) histogramMetric.value(value);
expectedValuesPtrn = new String[] { "test_registry_test_histogram_0_50.* 3", "test_registry_test_histogram_50_inf.* 3" };
assertTrue("Updated histogram metrics should be exported via http", checkHttpMetrics(expectedValuesPtrn));
}
use of org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl in project ignite by apache.
the class GridMetricManager method onHistogramConfigChanged.
/**
* Change {@link HistogramMetric} instance configuration.
*
* @param name Metric name.
* @param bounds New bounds.
*/
private void onHistogramConfigChanged(String name, @Nullable long[] bounds) {
if (bounds == null)
return;
HistogramMetricImpl m = find(name, HistogramMetricImpl.class);
if (m == null)
return;
m.reset(bounds);
}
use of org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl in project ignite by apache.
the class GridCacheTransactionalAbstractMetricsSelfTest method testRollbackTime.
/**
*/
@Test
public void testRollbackTime() {
IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME);
HistogramMetricImpl m = metric("RollbackTime");
assertTrue(Arrays.stream(m.value()).allMatch(v -> v == 0));
try (Transaction tx = grid(0).transactions().txStart()) {
cache.put(1, 1);
tx.rollback();
}
assertEquals(1, Arrays.stream(m.value()).filter(v -> v == 1).count());
}
use of org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl in project ignite by apache.
the class MetricsConfigurationTest method testConfigRemovedOnCacheGroupRemove.
/**
* Tests metric configuration removed on registry remove.
*/
@Test
public void testConfigRemovedOnCacheGroupRemove() throws Exception {
String cacheRegName = cacheMetricsRegistryName("test", false);
String mname = metricName(cacheRegName, "GetTime");
checkOnStartAndRestart((g0, g1) -> {
CacheConfiguration<String, String> ccfg = new CacheConfiguration<>("test");
ccfg.setGroupName("group");
g0.createCache(ccfg);
awaitPartitionMapExchange();
HistogramMetricImpl getTime = g0.context().metric().registry(cacheRegName).findMetric("GetTime");
assertNotEquals(BOUNDS.length, getTime.bounds().length);
metricsBean(g0).configureHistogramMetric(mname, BOUNDS);
assertArrayEquals(BOUNDS, g0.context().metric().registry(cacheRegName).<HistogramMetric>findMetric("GetTime").bounds());
assertArrayEquals(BOUNDS, g1.context().metric().registry(cacheRegName).<HistogramMetric>findMetric("GetTime").bounds());
}, (g0, g1) -> {
assertArrayEquals(BOUNDS, g0.context().metric().registry(cacheRegName).<HistogramMetric>findMetric("GetTime").bounds());
assertArrayEquals(BOUNDS, g1.context().metric().registry(cacheRegName).<HistogramMetric>findMetric("GetTime").bounds());
g0.destroyCache("test");
awaitPartitionMapExchange();
assertNull(g0.context().distributedMetastorage().read(mname));
assertNull(g1.context().distributedMetastorage().read(mname));
});
}
use of org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl in project ignite by apache.
the class MetricsSelfTest method testHistogramNames.
/**
*/
@Test
public void testHistogramNames() throws Exception {
HistogramMetricImpl h = new HistogramMetricImpl("test", null, new long[] { 10, 50, 500 });
String[] names = histogramBucketNames(h);
assertArrayEquals(new String[] { "test_0_10", "test_10_50", "test_50_500", "test_500_inf" }, names);
}
Aggregations