Search in sources :

Example 1 with TimestampedValue

use of org.apache.gobblin.metrics.test.TimestampedValue in project incubator-gobblin by apache.

the class TestInfluxDB method write.

private void write(String lineProtocol) {
    String[] split = lineProtocol.split(" ");
    String key = split[0];
    String value = split[1].substring(split[1].indexOf('=') + 1, split[1].length());
    long timestamp = Long.valueOf(split[2]) / 1000000l;
    data.put(key, new TimestampedValue(timestamp, value));
}
Also used : TimestampedValue(org.apache.gobblin.metrics.test.TimestampedValue)

Example 2 with TimestampedValue

use of org.apache.gobblin.metrics.test.TimestampedValue in project incubator-gobblin by apache.

the class GraphiteEventReporterTest method testSimpleEvent.

@Test
public void testSimpleEvent() throws IOException {
    try (MetricContext metricContext = MetricContext.builder(this.getClass().getCanonicalName() + ".testGraphiteReporter1").build();
        GraphiteEventReporter graphiteEventReporter = getBuilder(metricContext).withEmitValueAsKey(false).build()) {
        Map<String, String> metadata = Maps.newHashMap();
        metadata.put(JobEvent.METADATA_JOB_ID, "job1");
        metadata.put(TaskEvent.METADATA_TASK_ID, "task1");
        metricContext.submitEvent(GobblinTrackingEvent.newBuilder().setName(JobEvent.TASKS_SUBMITTED).setNamespace(NAMESPACE).setMetadata(metadata).build());
        try {
            Thread.sleep(100);
        } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
        }
        graphiteEventReporter.report();
        try {
            Thread.sleep(100);
        } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
        }
        TimestampedValue retrievedEvent = graphiteSender.getMetric("gobblin.metrics.job1.task1.events.TasksSubmitted");
        Assert.assertEquals(retrievedEvent.getValue(), "0");
        Assert.assertTrue(retrievedEvent.getTimestamp() <= (System.currentTimeMillis() / 1000l));
    }
}
Also used : TimestampedValue(org.apache.gobblin.metrics.test.TimestampedValue) MetricContext(org.apache.gobblin.metrics.MetricContext) Test(org.testng.annotations.Test)

Example 3 with TimestampedValue

use of org.apache.gobblin.metrics.test.TimestampedValue in project incubator-gobblin by apache.

the class InfluxDBEventReporterTest method testSimpleEvent.

@Test
public void testSimpleEvent() throws IOException {
    try (MetricContext metricContext = MetricContext.builder(this.getClass().getCanonicalName() + ".testInfluxDBReporter1").build();
        InfluxDBEventReporter influxEventReporter = getBuilder(metricContext).build()) {
        Map<String, String> metadata = Maps.newHashMap();
        metadata.put(JobEvent.METADATA_JOB_ID, "job1");
        metadata.put(TaskEvent.METADATA_TASK_ID, "task1");
        metricContext.submitEvent(GobblinTrackingEvent.newBuilder().setName(JobEvent.TASKS_SUBMITTED).setNamespace(NAMESPACE).setMetadata(metadata).build());
        try {
            Thread.sleep(100);
        } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
        }
        influxEventReporter.report();
        try {
            Thread.sleep(100);
        } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
        }
        TimestampedValue retrievedEvent = influxDB.getMetric("gobblin.metrics.job1.task1.events.TasksSubmitted");
        Assert.assertEquals(retrievedEvent.getValue(), "0.0");
        Assert.assertTrue(retrievedEvent.getTimestamp() <= (System.currentTimeMillis()));
    }
}
Also used : TimestampedValue(org.apache.gobblin.metrics.test.TimestampedValue) MetricContext(org.apache.gobblin.metrics.MetricContext) Test(org.testng.annotations.Test)

Aggregations

TimestampedValue (org.apache.gobblin.metrics.test.TimestampedValue)3 MetricContext (org.apache.gobblin.metrics.MetricContext)2 Test (org.testng.annotations.Test)2