use of com.newrelic.agent.introspec.ErrorEvent in project newrelic-java-agent by newrelic.
the class IntrospectorImplTest method testErrorOutsideTransaction.
@Test
public void testErrorOutsideTransaction() {
Throwable throwable = new Throwable("MyTest");
ServiceFactory.getRPMService().getErrorService().reportException(throwable);
// data check
Collection<String> txNames = impl.getTransactionNames();
Assert.assertEquals(0, txNames.size());
Collection<Error> errors1 = impl.getErrors();
Assert.assertEquals(1, errors1.size());
Error error1 = errors1.iterator().next();
Assert.assertEquals("MyTest", error1.getErrorMessage());
Assert.assertEquals(throwable, error1.getThrowable());
Collection<ErrorEvent> events = impl.getErrorEvents();
Assert.assertEquals(1, events.size());
ErrorEvent event = events.iterator().next();
// well that seems wrong - but that seems to be what we name all errors
Assert.assertEquals("TransactionError", event.getType());
Assert.assertEquals("MyTest", event.getErrorMessage());
Assert.assertEquals("java.lang.Throwable", event.getErrorClass());
Assert.assertEquals("Unknown", event.getTransactionName());
}
use of com.newrelic.agent.introspec.ErrorEvent in project newrelic-java-agent by newrelic.
the class IntrospectorImplTest method testErrorInTx.
@Test
public void testErrorInTx() {
// transaction
Transaction.getTransaction();
Tracer rootTracer = createOtherTracer("rootOnly");
Transaction.getTransaction().getTransactionActivity().tracerStarted(rootTracer);
Throwable throwable = new Throwable("MyTest");
Transaction.getTransaction().setThrowable(throwable, TransactionErrorPriority.TRACER, false);
rootTracer.finish(RETURN_OPCODE, 0);
// data check
Collection<String> txNames = impl.getTransactionNames();
Assert.assertEquals(1, txNames.size());
Assert.assertEquals("OtherTransaction/rootOnly", txNames.iterator().next());
Collection<Error> errors1 = impl.getErrors();
Collection<Error> errors2 = impl.getErrorsForTransaction("OtherTransaction/rootOnly");
Assert.assertEquals(1, errors1.size());
Assert.assertEquals(1, errors2.size());
Error error1 = errors1.iterator().next();
Assert.assertEquals(error1, errors2.iterator().next());
Assert.assertEquals("MyTest", error1.getErrorMessage());
Assert.assertEquals(throwable, error1.getThrowable());
Assert.assertEquals(1, impl.getTransactionEvents(txNames.iterator().next()).size());
Collection<ErrorEvent> events = impl.getErrorEvents();
Assert.assertEquals(1, events.size());
ErrorEvent event1 = events.iterator().next();
Assert.assertEquals("TransactionError", event1.getType());
Assert.assertEquals("MyTest", event1.getErrorMessage());
Assert.assertEquals("java.lang.Throwable", event1.getErrorClass());
Assert.assertEquals("OtherTransaction/rootOnly", event1.getTransactionName());
Collection<ErrorEvent> txEvents = impl.getErrorEventsForTransaction("OtherTransaction/rootOnly");
Assert.assertEquals(1, txEvents.size());
Event event2 = events.iterator().next();
Assert.assertEquals("TransactionError", event2.getType());
Assert.assertEquals(event1, event2);
}
use of com.newrelic.agent.introspec.ErrorEvent in project newrelic-java-agent by newrelic.
the class BasicRequestsTest method testUncaughtException.
@Test
public void testUncaughtException() {
try {
client.throwException("Blocking");
} catch (Exception e) {
}
String fullMethod = "helloworld.Greeter/ThrowException";
String clientTxName = "OtherTransaction/Custom/app.TestClient/throwException";
String serverTxName = "WebTransaction/gRPC/helloworld.Greeter/ThrowException";
ValidationHelper.validateExceptionGrpcInteraction(server, clientTxName, serverTxName, fullMethod, "UNARY", "Blocking", 2);
Introspector introspector = InstrumentationTestRunner.getIntrospector();
Collection<ErrorEvent> errorEvents = introspector.getErrorEvents();
CatHelper.verifyOneSuccessfulCat(introspector, clientTxName, serverTxName);
assertEquals(2, errorEvents.size());
}
use of com.newrelic.agent.introspec.ErrorEvent in project newrelic-java-agent by newrelic.
the class GrpcErrorsTest method testCaughtException.
@Test
public void testCaughtException() {
try {
client.throwCaughtException("Blocking");
} catch (Exception e) {
}
String fullMethod = "helloworld.Greeter/ThrowCaughtException";
String clientTxName = "OtherTransaction/Custom/app.TestClient/throwCaughtException";
String serverTxName = "WebTransaction/gRPC/helloworld.Greeter/ThrowCaughtException";
ValidationHelper.validateExceptionGrpcInteraction(server, clientTxName, serverTxName, fullMethod, "UNARY", "Blocking", 10);
Introspector introspector = InstrumentationTestRunner.getIntrospector();
Collection<ErrorEvent> errorEvents = introspector.getErrorEvents();
CatHelper.verifyOneSuccessfulCat(introspector, clientTxName, serverTxName);
// Disabling the gRPC error capture prevents error events from being created
assertEquals(0, errorEvents.size());
}
use of com.newrelic.agent.introspec.ErrorEvent in project newrelic-java-agent by newrelic.
the class BasicRequestsTest method testCaughtException.
@Test
public void testCaughtException() {
try {
client.throwCaughtException("Blocking");
} catch (Exception e) {
}
String fullMethod = "helloworld.Greeter/ThrowCaughtException";
String clientTxName = "OtherTransaction/Custom/app.TestClient/throwCaughtException";
String serverTxName = "WebTransaction/gRPC/helloworld.Greeter/ThrowCaughtException";
ValidationHelper.validateExceptionGrpcInteraction(server, clientTxName, serverTxName, fullMethod, "UNARY", "Blocking", 10);
Introspector introspector = InstrumentationTestRunner.getIntrospector();
Collection<ErrorEvent> errorEvents = introspector.getErrorEvents();
CatHelper.verifyOneSuccessfulCat(introspector, clientTxName, serverTxName);
assertEquals(1, errorEvents.size());
}
Aggregations