Search in sources :

Example 1 with Issue

use of org.apache.gobblin.runtime.troubleshooter.Issue in project incubator-gobblin by apache.

the class AutoTroubleshooterLogAppender method append.

@Override
protected void append(LoggingEvent event) {
    processedEventCount.incrementAndGet();
    Issue issue = convertToIssue(event);
    try {
        repository.put(issue);
    } catch (TroubleshooterException e) {
        if (reportedRepositoryError.compareAndSet(false, true)) {
            log.warn("Failed to save the issue to the repository", e);
        }
    }
}
Also used : TroubleshooterException(org.apache.gobblin.runtime.troubleshooter.TroubleshooterException) Issue(org.apache.gobblin.runtime.troubleshooter.Issue)

Example 2 with Issue

use of org.apache.gobblin.runtime.troubleshooter.Issue in project incubator-gobblin by apache.

the class AutoTroubleshooterLogAppenderTest method canLogException.

@Test
public void canLogException() throws Exception {
    Exception exception;
    try {
        // Throwing exception to get a real stack trace in it
        throw new IOException("test exception");
    } catch (Exception e) {
        exception = e;
    }
    appender.append(new LoggingEvent(log.getName(), log, System.currentTimeMillis(), Level.ERROR, "test message", exception));
    Issue issue = issueRepository.getAll().get(0);
    Assert.assertEquals(issue.getSeverity(), IssueSeverity.ERROR);
    Assert.assertTrue(issue.getSummary().contains("test message"));
    Assert.assertTrue(issue.getSummary().contains("test exception"));
    Assert.assertTrue(issue.getCode().length() > 1);
    Assert.assertTrue(issue.getDetails().contains("IOException"));
}
Also used : LoggingEvent(org.apache.log4j.spi.LoggingEvent) Issue(org.apache.gobblin.runtime.troubleshooter.Issue) IOException(java.io.IOException) IOException(java.io.IOException) InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) Test(org.testng.annotations.Test)

Example 3 with Issue

use of org.apache.gobblin.runtime.troubleshooter.Issue in project incubator-gobblin by apache.

the class AutoTroubleshooterLogAppenderTest method canLogExceptionWithSpecificErrorCode.

@Test
public void canLogExceptionWithSpecificErrorCode() throws Exception {
    Exception exception;
    try {
        throw new TestException("test exception", "TestCode");
    } catch (Exception e) {
        exception = e;
    }
    appender.append(new LoggingEvent(log.getName(), log, System.currentTimeMillis(), Level.ERROR, "test message", exception));
    Issue issue = issueRepository.getAll().get(0);
    Assert.assertEquals(issue.getSeverity(), IssueSeverity.ERROR);
    Assert.assertEquals(issue.getCode(), "TestCode");
}
Also used : LoggingEvent(org.apache.log4j.spi.LoggingEvent) Issue(org.apache.gobblin.runtime.troubleshooter.Issue) IOException(java.io.IOException) InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) Test(org.testng.annotations.Test)

Example 4 with Issue

use of org.apache.gobblin.runtime.troubleshooter.Issue in project incubator-gobblin by apache.

the class AutoTroubleshooterLogAppenderTest method willGetSameErrorCodesForSameStackTraces.

@Test
public void willGetSameErrorCodesForSameStackTraces() throws Exception {
    for (int i = 0; i < 5; i++) {
        Exception exception;
        try {
            try {
                throw new InvalidOperationException("test inner exception " + i);
            } catch (Exception inner) {
                throw new IOException("test outer exception " + i, inner);
            }
        } catch (Exception e) {
            exception = e;
        }
        appender.append(new LoggingEvent(log.getName(), log, System.currentTimeMillis(), Level.ERROR, "test message", exception));
    }
    List<Issue> issues = issueRepository.getAll();
    // all issues should have the same error code and get deduplicated
    Assert.assertEquals(issues.size(), 1);
}
Also used : LoggingEvent(org.apache.log4j.spi.LoggingEvent) Issue(org.apache.gobblin.runtime.troubleshooter.Issue) InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) IOException(java.io.IOException) IOException(java.io.IOException) InvalidOperationException(org.apache.hadoop.hive.metastore.api.InvalidOperationException) Test(org.testng.annotations.Test)

Example 5 with Issue

use of org.apache.gobblin.runtime.troubleshooter.Issue in project incubator-gobblin by apache.

the class AutomaticTroubleshooterImpl method reportJobIssuesAsEvents.

@Override
public void reportJobIssuesAsEvents(EventSubmitter eventSubmitter) throws TroubleshooterException {
    if (config.isDisableEventReporting()) {
        log.info("Troubleshooter will not report issues as GobblinTrackingEvents. Remove the following property to re-enable it: " + ConfigurationKeys.TROUBLESHOOTER_DISABLE_EVENT_REPORTING);
        return;
    }
    List<Issue> issues = issueRepository.getAll();
    log.info("Reporting troubleshooter issues as Gobblin tracking events. Issue count: " + issues.size());
    for (Issue issue : issues) {
        IssueEventBuilder eventBuilder = new IssueEventBuilder(IssueEventBuilder.JOB_ISSUE);
        eventBuilder.setIssue(issue);
        eventSubmitter.submit(eventBuilder);
    }
}
Also used : IssueEventBuilder(org.apache.gobblin.runtime.troubleshooter.IssueEventBuilder) Issue(org.apache.gobblin.runtime.troubleshooter.Issue)

Aggregations

Issue (org.apache.gobblin.runtime.troubleshooter.Issue)48 Test (org.testng.annotations.Test)32 TroubleshooterException (org.apache.gobblin.runtime.troubleshooter.TroubleshooterException)10 ArrayList (java.util.ArrayList)8 LoggingEvent (org.apache.log4j.spi.LoggingEvent)8 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)6 Connection (java.sql.Connection)4 PreparedStatement (java.sql.PreparedStatement)4 SQLException (java.sql.SQLException)4 Random (java.util.Random)4 TextStringBuilder (org.apache.commons.text.TextStringBuilder)4 StringMap (com.linkedin.data.template.StringMap)2 Type (java.lang.reflect.Type)2 ResultSet (java.sql.ResultSet)2 Timestamp (java.sql.Timestamp)2 ZonedDateTime (java.time.ZonedDateTime)2 WorkUnitState (org.apache.gobblin.configuration.WorkUnitState)2 IssueEventBuilder (org.apache.gobblin.runtime.troubleshooter.IssueEventBuilder)2