use of com.newrelic.agent.errors.ThrowableError in project newrelic-java-agent by newrelic.
the class IntrospectorErrorService method reportError.
@Override
protected void reportError(TracedError error, TransactionData transactionData, TransactionStats transactionStats) {
if (error == null) {
return;
}
if (error instanceof ThrowableError && getErrorAnalyzer().isIgnoredError(HttpURLConnection.HTTP_OK, ((ThrowableError) error).getThrowable())) {
return;
}
ErrorEvent event = ErrorServiceImpl.createErrorEvent("TestApp", error, transactionData, transactionStats);
if (transactionData == null) {
errorsOutsideTransactions.add(new ErrorImpl(error));
errorEventsOutsideTransactions.add(new ErrorEventImpl(event));
} else {
String txName = transactionData.getPriorityTransactionName().getName();
errors.put(txName, new ErrorImpl(error));
errorEvents.put(txName, new ErrorEventImpl(event));
}
}
use of com.newrelic.agent.errors.ThrowableError in project newrelic-java-agent by newrelic.
the class DataCollectionConfigCrossAgentTest method createAndVerifyErrorEvent.
private void createAndVerifyErrorEvent(Long expectedCount, Long expectedEndpointCount) {
ErrorServiceImpl errorService = new ErrorServiceImpl(APP_NAME);
rpmService.setErrorService(errorService);
long eventsToCreate = 1;
if (expectedCount > 1) {
eventsToCreate = expectedCount;
}
for (long i = 0; i < eventsToCreate; i++) {
ThrowableError error = ThrowableError.builder(errorService.getErrorCollectorConfig(), APP_NAME, "metric", new Throwable(), System.currentTimeMillis()).build();
errorService.reportError(error);
}
// Verify that the correct number of events were stored in the reservoir
DistributedSamplingPriorityQueue<ErrorEvent> eventQueue = errorService.getReservoir(APP_NAME);
assertNotNull(eventQueue);
assertEquals(expectedCount.intValue(), eventQueue.size());
// Verify that we sent (or didn't send) the appropriate events
errorService.harvestEvents(APP_NAME);
int errorEventsSeen = rpmService.getErrorEventsSeen();
assertEquals(expectedEndpointCount.intValue(), errorEventsSeen);
}
use of com.newrelic.agent.errors.ThrowableError in project newrelic-java-agent by newrelic.
the class DataCollectionConfigCrossAgentTest method createAndVerifyErrorTrace.
private void createAndVerifyErrorTrace(Long expectedCount, Long expectedEndpointCount) {
ErrorServiceImpl errorService = new ErrorServiceImpl(APP_NAME);
rpmService.setErrorService(errorService);
long eventsToCreate = 1;
if (expectedCount > 1) {
eventsToCreate = expectedCount;
}
for (long i = 0; i < eventsToCreate; i++) {
ThrowableError error = ThrowableError.builder(errorService.getErrorCollectorConfig(), APP_NAME, "metric", new Throwable(), System.currentTimeMillis()).build();
errorService.reportError(error);
}
// Verify that the correct number of traces were stored in the reservoir
assertEquals(expectedCount.intValue(), errorService.getTracedErrorsCount());
// Verify that we sent (or didn't send) the appropriate traces
errorService.harvestTracedErrors(APP_NAME, new StatsEngineImpl());
int errorTracesSeen = rpmService.getErrorTracesSeen();
assertEquals(expectedEndpointCount.intValue(), errorTracesSeen);
}
Aggregations