Search in sources :

Example 1 with Event

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);
}
Also used : Tracer(com.newrelic.agent.tracers.Tracer) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) ErrorEvent(com.newrelic.agent.introspec.ErrorEvent) Error(com.newrelic.agent.introspec.Error) Event(com.newrelic.agent.introspec.Event) ErrorEvent(com.newrelic.agent.introspec.ErrorEvent) Test(org.junit.Test)

Example 2 with Event

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;
}
Also used : ArrayList(java.util.ArrayList) CustomInsightsEvent(com.newrelic.agent.model.CustomInsightsEvent) AnalyticsEvent(com.newrelic.agent.model.AnalyticsEvent) Event(com.newrelic.agent.introspec.Event) CustomInsightsEvent(com.newrelic.agent.model.CustomInsightsEvent)

Aggregations

Event (com.newrelic.agent.introspec.Event)2 Error (com.newrelic.agent.introspec.Error)1 ErrorEvent (com.newrelic.agent.introspec.ErrorEvent)1 AnalyticsEvent (com.newrelic.agent.model.AnalyticsEvent)1 CustomInsightsEvent (com.newrelic.agent.model.CustomInsightsEvent)1 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)1 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)1 Tracer (com.newrelic.agent.tracers.Tracer)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1