use of org.apache.heron.spi.metricsmgr.metrics.ExceptionInfo in project heron by twitter.
the class MetricsManagerServerTest method testMetricsManagerServer.
/**
* Method: addSinkCommunicator(Communicator<MetricsRecord> communicator)
*/
@Test
public void testMetricsManagerServer() throws InterruptedException {
String name = "test_communicator";
CountDownLatch offersLatch = new CountDownLatch(MESSAGE_SIZE);
Communicator<MetricsRecord> sinkCommunicator = CommunicatorTestHelper.spyCommunicator(new Communicator<MetricsRecord>(), offersLatch);
metricsManagerServer.addSinkCommunicator(name, sinkCommunicator);
serverTester.start();
HeronServerTester.await(offersLatch);
int messages = 0;
while (!sinkCommunicator.isEmpty()) {
int exceptions = 0;
int metrics = 0;
MetricsRecord record = sinkCommunicator.poll();
Assert.assertEquals("hostname:0/component/instance-id", record.getSource());
Assert.assertEquals("default", record.getContext());
for (MetricsInfo info : record.getMetrics()) {
Assert.assertEquals(METRIC_NAME, info.getName());
Assert.assertEquals(METRIC_VALUE, info.getValue());
metrics++;
}
Assert.assertEquals(METRICS_COUNT, metrics);
for (ExceptionInfo info : record.getExceptions()) {
Assert.assertEquals(STACK_TRACE, info.getStackTrace());
Assert.assertEquals(LAST_TIME, info.getLastTime());
Assert.assertEquals(FIRST_TIME, info.getFirstTime());
Assert.assertEquals(LOGGING, info.getLogging());
Assert.assertEquals(EXCEPTION_COUNT, info.getCount());
exceptions++;
}
Assert.assertEquals(METRICS_COUNT, exceptions);
messages++;
}
Assert.assertEquals(MESSAGE_SIZE, messages);
}
use of org.apache.heron.spi.metricsmgr.metrics.ExceptionInfo in project heron by twitter.
the class SinkExecutorTest method constructMetricsRecord.
private MetricsRecord constructMetricsRecord() {
List<MetricsInfo> metricsInfos = new ArrayList<>();
// We add EXPECTED_RECORDS MetricsInfo into a MetricsRecord
for (int i = 0; i < EXPECTED_RECORDS; i++) {
MetricsInfo metricsInfo = new MetricsInfo(METRICS_NAME + i, METRICS_VALUE + i);
metricsInfos.add(metricsInfo);
}
// We add EXPECTED_RECORDS ExceptionInfo into a MetricsRecord
List<ExceptionInfo> exceptionInfos = new ArrayList<>();
for (int i = 0; i < EXPECTED_RECORDS; i++) {
String stackTrace = EXCEPTION_STACK_TRACE + i;
String lastTime = EXCEPTION_LAST_TIME + i;
String firstTime = EXCEPTION_FIRST_TIME + i;
String logging = EXCEPTION_LOGGING + i;
ExceptionInfo info = new ExceptionInfo(stackTrace, lastTime, firstTime, i, logging);
exceptionInfos.add(info);
}
return new MetricsRecord(RECORD_SOURCE, metricsInfos, exceptionInfos, RECORD_CONTEXT);
}
Aggregations