use of org.apache.heron.spi.metricsmgr.metrics.MetricsInfo 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);
}
use of org.apache.heron.spi.metricsmgr.metrics.MetricsInfo in project heron by twitter.
the class PrometheusSinkTests method testResponseWhenMetricNamesHaveAnInstanceId.
@Test
public void testResponseWhenMetricNamesHaveAnInstanceId() throws IOException {
Iterable<MetricsInfo> infos = Arrays.asList(new MetricsInfo("__connection_buffer_by_instanceid/container_1_word_5/packets", "1.0"), new MetricsInfo("__time_spent_back_pressure_by_compid/container_1_exclaim1_1", "1.0"), new MetricsInfo("__client_stmgr-92/__ack_tuples_to_stmgrs", "1.0"), new MetricsInfo("__instance_bytes_received/1", "1.0"));
records = Arrays.asList(newRecord("machine/__stmgr__/stmgr-1", infos, Collections.emptyList()));
PrometheusTestSink sink = new PrometheusTestSink();
sink.init(defaultConf, context);
for (MetricsRecord r : records) {
sink.processRecord(r);
}
final String topology = "testTopology";
final List<String> expectedLines = Arrays.asList(createMetric(topology, "__stmgr__", "stmgr-1", "connection_buffer_by_instanceid_packets", "container_1_word_5", "1.0"), createMetric(topology, "__stmgr__", "stmgr-1", "time_spent_back_pressure_by_compid", "container_1_exclaim1_1", "1.0"), createMetric(topology, "__stmgr__", "stmgr-1", "client_stmgr_ack_tuples_to_stmgrs", "stmgr-92", "1.0"), createMetric(topology, "__stmgr__", "stmgr-1", "instance_bytes_received", "1", "1.0"));
final Set<String> generatedLines = new HashSet<>(Arrays.asList(new String(sink.generateResponse()).split("\n")));
assertEquals(expectedLines.size(), generatedLines.size());
expectedLines.forEach((String line) -> {
assertTrue(generatedLines.contains(line));
});
}
Aggregations