use of com.hazelcast.internal.metrics.Probe in project hazelcast by hazelcast.
the class FieldProbeTest method getLong.
public void getLong(String fieldName, int expectedValue) throws Exception {
SomeSource source = new SomeSource();
Field field = source.getClass().getDeclaredField(fieldName);
Probe probe = field.getAnnotation(Probe.class);
FieldProbe fieldProbe = createFieldProbe(field, probe, new SourceMetadata(SomeSource.class));
LongFieldProbe longFieldProbe = assertInstanceOf(LongFieldProbe.class, fieldProbe);
long value = longFieldProbe.get(source);
assertEquals(expectedValue, value);
}
use of com.hazelcast.internal.metrics.Probe in project hazelcast by hazelcast.
the class FieldProbeTest method getDouble.
public void getDouble(String fieldName, double expected) throws Exception {
SomeSource source = new SomeSource();
Field field = source.getClass().getDeclaredField(fieldName);
Probe probe = field.getAnnotation(Probe.class);
FieldProbe fieldProbe = createFieldProbe(field, probe, new SourceMetadata(SomeSource.class));
assertInstanceOf(DoubleFieldProbe.class, fieldProbe);
DoubleFieldProbe doubleFieldProbe = (DoubleFieldProbe) fieldProbe;
double value = doubleFieldProbe.get(source);
assertEquals(expected, value, 0.1);
}
use of com.hazelcast.internal.metrics.Probe in project hazelcast by hazelcast.
the class MethodProbeTest method testGeneratedMethodProbeName_removeGetPrefix.
@Test
public void testGeneratedMethodProbeName_removeGetPrefix() throws NoSuchMethodException {
SomeSource source = new SomeSource();
Method method = source.getClass().getDeclaredMethod("getSomeIntegerMethod");
Probe probe = method.getAnnotation(Probe.class);
MethodProbe methodProbe = createMethodProbe(method, probe, new SourceMetadata(SomeSource.class));
MetricsRegistryImpl metricsRegistry = new MetricsRegistryImpl(mock(ILogger.class), ProbeLevel.DEBUG);
methodProbe.register(metricsRegistry, source, "prefix");
Set<String> names = metricsRegistry.getNames();
assertEquals(1, names.size());
String probeName = getItemAtPositionOrNull(names, 0);
assertEquals("[metric=prefix.someIntegerMethod]", probeName);
}
Aggregations