Search in sources :

Example 16 with MetricsSnapshot

use of org.apache.samza.metrics.reporter.MetricsSnapshot in project samza by apache.

the class TestDiagnosticsStreamMessage method testSerdeEmptySamzaEpochIdInHeader.

@Test
public void testSerdeEmptySamzaEpochIdInHeader() {
    DiagnosticsStreamMessage diagnosticsStreamMessage = getDiagnosticsStreamMessage(Optional.empty());
    MetricsSnapshot metricsSnapshot = diagnosticsStreamMessage.convertToMetricsSnapshot();
    MetricsHeader expectedHeader = new MetricsHeader(JOB_NAME, JOB_ID, CONTAINER_NAME, EXECUTION_ENV_CONTAINER_ID, Optional.empty(), DiagnosticsManager.class.getName(), TASK_CLASS_VERSION, SAMZA_VERSION, HOSTNAME, timestamp, resetTimestamp);
    Assert.assertEquals(metricsSnapshot.getHeader(), expectedHeader);
    DiagnosticsStreamMessage convertedDiagnosticsStreamMessage = DiagnosticsStreamMessage.convertToDiagnosticsStreamMessage(metricsSnapshot);
    Assert.assertEquals(convertedDiagnosticsStreamMessage, diagnosticsStreamMessage);
}
Also used : MetricsHeader(org.apache.samza.metrics.reporter.MetricsHeader) MetricsSnapshot(org.apache.samza.metrics.reporter.MetricsSnapshot) Test(org.junit.Test)

Example 17 with MetricsSnapshot

use of org.apache.samza.metrics.reporter.MetricsSnapshot in project samza by apache.

the class TestDiagnosticsManager method validateMetricsHeader.

private void validateMetricsHeader(OutgoingMessageEnvelope outgoingMessageEnvelope, long sendTime) {
    // Validate the outgoing message
    Assert.assertTrue(outgoingMessageEnvelope.getSystemStream().equals(diagnosticsSystemStream));
    MetricsSnapshot metricsSnapshot = new MetricsSnapshotSerdeV2().fromBytes((byte[]) outgoingMessageEnvelope.getMessage());
    MetricsHeader expectedHeader = new MetricsHeader(JOB_NAME, JOB_ID, "samza-container-0", EXECUTION_ENV_CONTAINER_ID, Optional.of(SAMZA_EPOCH_ID), DiagnosticsManager.class.getName(), TASK_CLASS_VERSION, SAMZA_VERSION, HOSTNAME, sendTime, RESET_TIME);
    Assert.assertEquals(expectedHeader, metricsSnapshot.getHeader());
}
Also used : MetricsHeader(org.apache.samza.metrics.reporter.MetricsHeader) MetricsSnapshot(org.apache.samza.metrics.reporter.MetricsSnapshot) MetricsSnapshotSerdeV2(org.apache.samza.serializers.MetricsSnapshotSerdeV2)

Aggregations

MetricsSnapshot (org.apache.samza.metrics.reporter.MetricsSnapshot)17 Test (org.junit.Test)12 MetricsSnapshotSerdeV2 (org.apache.samza.serializers.MetricsSnapshotSerdeV2)9 MetricsHeader (org.apache.samza.metrics.reporter.MetricsHeader)6 HashMap (java.util.HashMap)4 SamzaException (org.apache.samza.SamzaException)4 Map (java.util.Map)3 Metrics (org.apache.samza.metrics.reporter.Metrics)2 OutgoingMessageEnvelope (org.apache.samza.system.OutgoingMessageEnvelope)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 File (java.io.File)1 BoundedList (org.apache.samza.diagnostics.BoundedList)1 DiagnosticsExceptionEvent (org.apache.samza.diagnostics.DiagnosticsExceptionEvent)1 LocalContainerRunner (org.apache.samza.runtime.LocalContainerRunner)1