Search in sources :

Example 1 with DiagnosticsExceptionEvent

use of org.apache.samza.diagnostics.DiagnosticsExceptionEvent in project samza by apache.

the class TestMetricsSnapshotSerdeV2 method metricsSnapshot.

private static MetricsSnapshot metricsSnapshot(Exception exception, boolean includeSamzaEpochId) {
    MetricsHeader metricsHeader;
    if (includeSamzaEpochId) {
        metricsHeader = new MetricsHeader("jobName", "i001", "container 0", "test container ID", Optional.of("epoch-123"), "source", "300.14.25.1", "1", "1", 1, 1);
    } else {
        metricsHeader = new MetricsHeader("jobName", "i001", "container 0", "test container ID", "source", "300.14.25.1", "1", "1", 1, 1);
    }
    BoundedList<DiagnosticsExceptionEvent> boundedList = new BoundedList<>("exceptions");
    DiagnosticsExceptionEvent diagnosticsExceptionEvent = new DiagnosticsExceptionEvent(1, exception, new HashMap<>());
    boundedList.add(diagnosticsExceptionEvent);
    Map<String, Map<String, Object>> metricMessage = new HashMap<>();
    Map<String, Object> samzaContainerMetrics = new HashMap<>();
    samzaContainerMetrics.put("commit-calls", 1);
    metricMessage.put("org.apache.samza.container.SamzaContainerMetrics", samzaContainerMetrics);
    Map<String, Object> exceptions = new HashMap<>();
    exceptions.put("exceptions", boundedList.getValues());
    metricMessage.put("org.apache.samza.exceptions", exceptions);
    return new MetricsSnapshot(metricsHeader, new Metrics(metricMessage));
}
Also used : HashMap(java.util.HashMap) MetricsSnapshot(org.apache.samza.metrics.reporter.MetricsSnapshot) MetricsHeader(org.apache.samza.metrics.reporter.MetricsHeader) Metrics(org.apache.samza.metrics.reporter.Metrics) DiagnosticsExceptionEvent(org.apache.samza.diagnostics.DiagnosticsExceptionEvent) HashMap(java.util.HashMap) Map(java.util.Map) BoundedList(org.apache.samza.diagnostics.BoundedList)

Example 2 with DiagnosticsExceptionEvent

use of org.apache.samza.diagnostics.DiagnosticsExceptionEvent in project samza by apache.

the class SimpleDiagnosticsAppender method append.

@Override
protected void append(LoggingEvent loggingEvent) {
    try {
        // if an event with a non-null throwable is received => exception event
        if (loggingEvent.getThrowableInformation() != null) {
            DiagnosticsExceptionEvent diagnosticsExceptionEvent = new DiagnosticsExceptionEvent(loggingEvent.timeStamp, loggingEvent.getThrowableInformation().getThrowable(), loggingEvent.getProperties());
            diagnosticsManager.addExceptionEvent(diagnosticsExceptionEvent);
        }
    } catch (Exception e) {
        // blanket catch of all exceptions so as to not impact any job
        System.err.println("Exception in logging event parsing " + e);
    }
}
Also used : DiagnosticsExceptionEvent(org.apache.samza.diagnostics.DiagnosticsExceptionEvent)

Example 3 with DiagnosticsExceptionEvent

use of org.apache.samza.diagnostics.DiagnosticsExceptionEvent in project samza by apache.

the class SimpleDiagnosticsAppender method append.

@Override
public void append(LogEvent logEvent) {
    try {
        // if an event with a non-null throwable is received => exception event
        if (logEvent.getThrown() != null) {
            DiagnosticsExceptionEvent diagnosticsExceptionEvent = new DiagnosticsExceptionEvent(logEvent.getTimeMillis(), logEvent.getThrown(), logEvent.getContextData().toMap());
            diagnosticsManager.addExceptionEvent(diagnosticsExceptionEvent);
        }
    } catch (Exception e) {
        // blanket catch of all exceptions so as to not impact any job
        System.err.println("Exception in logevent parsing " + e);
    }
}
Also used : DiagnosticsExceptionEvent(org.apache.samza.diagnostics.DiagnosticsExceptionEvent)

Aggregations

DiagnosticsExceptionEvent (org.apache.samza.diagnostics.DiagnosticsExceptionEvent)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BoundedList (org.apache.samza.diagnostics.BoundedList)1 Metrics (org.apache.samza.metrics.reporter.Metrics)1 MetricsHeader (org.apache.samza.metrics.reporter.MetricsHeader)1 MetricsSnapshot (org.apache.samza.metrics.reporter.MetricsSnapshot)1