Search in sources :

Example 1 with TracerList

use of com.newrelic.agent.TracerList in project newrelic-java-agent by newrelic.

the class SpanParentTest method testErrorAttributes.

@Test
public void testErrorAttributes() throws Exception {
    EnvironmentHolder holder = setupEnvironemntHolder("all_enabled_test");
    Header actualHeader = txnStarter(true);
    try {
        TransactionDataList transactionList = holder.getTransactionList();
        ServiceFactory.getHarvestService().harvestNow();
        assertEquals(1, transactionList.size());
        Collection<Tracer> tracers = transactionList.get(0).getTracers();
        Tracer tracer = ((TracerList) tracers).get(0);
        String expectedGuid = tracer.getGuid();
        String actualGuid = findGuid(actualHeader.getValue());
        Assert.assertEquals(expectedGuid, actualGuid);
        ErrorServiceImpl errorService = (ErrorServiceImpl) ServiceFactory.getRPMService().getErrorService();
        List<TracedError> tracedErrors = errorService.getAndClearTracedErrors();
        assertEquals(1, tracedErrors.size());
        TracedError errorTrace = tracedErrors.get(0);
        Map<String, ?> errorAtts = errorTrace.getIntrinsicAtts();
        Assert.assertNotNull(errorAtts.get("traceId"));
        Assert.assertNotNull(errorAtts.get("guid"));
        Assert.assertNotNull(errorAtts.get("priority"));
        Assert.assertNotNull(errorAtts.get("sampled"));
    } finally {
        holder.close();
    }
}
Also used : TransactionDataList(com.newrelic.agent.TransactionDataList) Header(org.apache.http.Header) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) TracedError(com.newrelic.agent.errors.TracedError) EnvironmentHolder(test.newrelic.test.agent.EnvironmentHolder) Tracer(com.newrelic.agent.tracers.Tracer) TracerList(com.newrelic.agent.TracerList) Test(org.junit.Test)

Aggregations

TracerList (com.newrelic.agent.TracerList)1 TransactionDataList (com.newrelic.agent.TransactionDataList)1 ErrorServiceImpl (com.newrelic.agent.errors.ErrorServiceImpl)1 TracedError (com.newrelic.agent.errors.TracedError)1 Tracer (com.newrelic.agent.tracers.Tracer)1 Header (org.apache.http.Header)1 Test (org.junit.Test)1 EnvironmentHolder (test.newrelic.test.agent.EnvironmentHolder)1