use of com.newrelic.agent.introspec.Event 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.Event in project newrelic-java-agent by newrelic.
the class IntrospectorInsightsService method getEvents.
public Collection<Event> getEvents(String type) {
List<CustomInsightsEvent> currentEvents = events.get(type);
if (currentEvents == null) {
return null;
}
List<Event> output = new ArrayList<>(currentEvents.size());
for (CustomInsightsEvent current : currentEvents) {
output.add(new EventImpl(current.getType(), current.getUserAttributesCopy()));
}
return output;
}
Aggregations