Search in sources :

Example 1 with ErrorCollectorConfig

use of com.newrelic.agent.config.ErrorCollectorConfig in project newrelic-java-agent by newrelic.

the class ErrorServiceImpl method refreshErrorCollectorConfig.

@VisibleForTesting
public void refreshErrorCollectorConfig(AgentConfig agentConfig) {
    ErrorCollectorConfig oldErrorConfig = errorCollectorConfig;
    errorCollectorConfig = agentConfig.getErrorCollectorConfig();
    errorAnalyzer = new ErrorAnalyzerImpl(errorCollectorConfig);
    if (errorCollectorConfig.isEnabled() == oldErrorConfig.isEnabled()) {
        return;
    }
    Agent.LOG.log(Level.INFO, errorCollectorConfig.isEnabled() ? "Errors will be sent to New Relic for {0}" : "Errors will not be sent to New Relic for {0}", appName);
}
Also used : ErrorCollectorConfig(com.newrelic.agent.config.ErrorCollectorConfig) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with ErrorCollectorConfig

use of com.newrelic.agent.config.ErrorCollectorConfig in project newrelic-java-agent by newrelic.

the class ErrorAnalyzerImplTest method ignoredStatusFollowsConfigNotStatusCodeMeaning.

@Test
public void ignoredStatusFollowsConfigNotStatusCodeMeaning() {
    ErrorCollectorConfig config = new TestErrorCollectorConfig().setIgnoreStatusCodes(HTTP_BAD_REQUEST, HTTP_ACCEPTED);
    ErrorAnalyzer target = new ErrorAnalyzerImpl(config);
    assertFalse(target.isIgnoredStatus(HTTP_OK));
    assertTrue(target.isIgnoredStatus(HTTP_ACCEPTED));
    assertTrue(target.isIgnoredStatus(HTTP_BAD_REQUEST));
    assertFalse(target.isIgnoredStatus(HTTP_UNAUTHORIZED));
    assertFalse(target.isIgnoredStatus(ErrorAnalyzer.NO_STATUS));
}
Also used : ErrorCollectorConfig(com.newrelic.agent.config.ErrorCollectorConfig) Test(org.junit.Test)

Example 3 with ErrorCollectorConfig

use of com.newrelic.agent.config.ErrorCollectorConfig in project newrelic-java-agent by newrelic.

the class ErrorAnalyzerImplTest method statusCodeOrThrowableAreReportable.

@Test
public void statusCodeOrThrowableAreReportable() {
    ErrorCollectorConfig config = new TestErrorCollectorConfig();
    ErrorAnalyzer target = new ErrorAnalyzerImpl(config);
    assertFalse(target.isReportable(HTTP_OK, (Throwable) null));
    assertTrue(target.isReportable(HTTP_OK, new Throwable("bye")));
    assertTrue(target.isReportable(HTTP_BAD_REQUEST, (Throwable) null));
    assertTrue(target.isReportable(HTTP_BAD_REQUEST, new Throwable("bye")));
}
Also used : ErrorCollectorConfig(com.newrelic.agent.config.ErrorCollectorConfig) TransactionThrowable(com.newrelic.agent.transaction.TransactionThrowable) Test(org.junit.Test)

Example 4 with ErrorCollectorConfig

use of com.newrelic.agent.config.ErrorCollectorConfig in project newrelic-java-agent by newrelic.

the class ErrorAnalyzerImplTest method nullErrorsAreNotExpected.

@Test
public void nullErrorsAreNotExpected() {
    ErrorCollectorConfig config = new TestErrorCollectorConfig().setExpectedErrors(new ExpectedErrorConfigImpl(MyThrowable.class.getName(), null), new ExpectedErrorConfigImpl(RuntimeException.class.getName(), "ignore_token"));
    ErrorAnalyzer target = new ErrorAnalyzerImpl(config);
    assertFalse(target.isExpectedError(HTTP_OK, null));
    assertFalse(target.isExpectedError(HTTP_OK, wrap(null)));
}
Also used : ErrorCollectorConfig(com.newrelic.agent.config.ErrorCollectorConfig) ExpectedErrorConfigImpl(com.newrelic.agent.config.ExpectedErrorConfigImpl) Test(org.junit.Test)

Example 5 with ErrorCollectorConfig

use of com.newrelic.agent.config.ErrorCollectorConfig in project newrelic-java-agent by newrelic.

the class ErrorAnalyzerImplTest method ignoredThrowableFollowsAnyCause.

@Test
public void ignoredThrowableFollowsAnyCause() {
    ErrorCollectorConfig config = new TestErrorCollectorConfig().setIgnoreErrors(new IgnoreErrorConfigImpl(MyThrowable.class.getName(), null));
    ErrorAnalyzer target = new ErrorAnalyzerImpl(config);
    assertTrue(target.isIgnoredThrowable(new MyThrowable("message")));
    assertTrue(target.isIgnoredThrowable(new Exception("other", new MyThrowable("message"))));
    assertFalse(target.isIgnoredThrowable(new Exception("other")));
}
Also used : ErrorCollectorConfig(com.newrelic.agent.config.ErrorCollectorConfig) IgnoreErrorConfigImpl(com.newrelic.agent.config.IgnoreErrorConfigImpl) Test(org.junit.Test)

Aggregations

ErrorCollectorConfig (com.newrelic.agent.config.ErrorCollectorConfig)34 Test (org.junit.Test)30 HashMap (java.util.HashMap)12 JSONArray (org.json.simple.JSONArray)9 JSONObject (org.json.simple.JSONObject)8 Map (java.util.Map)6 ExpectedErrorConfigImpl (com.newrelic.agent.config.ExpectedErrorConfigImpl)3 IgnoreErrorConfigImpl (com.newrelic.agent.config.IgnoreErrorConfigImpl)3 TransactionThrowable (com.newrelic.agent.transaction.TransactionThrowable)3 IOException (java.io.IOException)3 MockRPMService (com.newrelic.agent.MockRPMService)2 StripExceptionConfigImpl (com.newrelic.agent.config.StripExceptionConfigImpl)2 ThreadInfo (java.lang.management.ThreadInfo)2 ArrayList (java.util.ArrayList)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 MockDispatcher (com.newrelic.agent.MockDispatcher)1 MockDispatcherTracer (com.newrelic.agent.MockDispatcherTracer)1 MockServiceManager (com.newrelic.agent.MockServiceManager)1 TransactionDataTestBuilder (com.newrelic.agent.TransactionDataTestBuilder)1 AgentConfig (com.newrelic.agent.config.AgentConfig)1