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);
}
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));
}
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")));
}
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)));
}
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")));
}
Aggregations