Search in sources :

Example 11 with MetricsInfo

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);
}
Also used : MetricsInfo(org.apache.heron.spi.metricsmgr.metrics.MetricsInfo) MetricsRecord(org.apache.heron.spi.metricsmgr.metrics.MetricsRecord) ArrayList(java.util.ArrayList) ExceptionInfo(org.apache.heron.spi.metricsmgr.metrics.ExceptionInfo)

Example 12 with MetricsInfo

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));
    });
}
Also used : MetricsInfo(org.apache.heron.spi.metricsmgr.metrics.MetricsInfo) MetricsRecord(org.apache.heron.spi.metricsmgr.metrics.MetricsRecord) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

MetricsInfo (org.apache.heron.spi.metricsmgr.metrics.MetricsInfo)12 ExceptionInfo (org.apache.heron.spi.metricsmgr.metrics.ExceptionInfo)7 MetricsRecord (org.apache.heron.spi.metricsmgr.metrics.MetricsRecord)7 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 TopologyManager (org.apache.heron.proto.tmanager.TopologyManager)2 SinkContext (org.apache.heron.spi.metricsmgr.sink.SinkContext)2 Before (org.junit.Before)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Metrics (org.apache.heron.proto.system.Metrics)1