Search in sources :

Example 1 with MessagingTestServer

use of test.newrelic.test.agent.api.MessagingTestServer in project newrelic-java-agent by newrelic.

the class SpanParentTest method txnStarter.

@Trace(dispatcher = true)
private Header txnStarter(boolean noticeError) {
    Transaction txn = ServiceFactory.getServiceManager().getTransactionService().getTransaction(false);
    DistributedTracePayloadImpl payload = DistributedTracePayloadImpl.createDistributedTracePayload(null, txn.getGuid(), txn.getGuid(), 1.0f);
    txn.acceptDistributedTracePayload(payload.httpSafe());
    MessagingTestServer server = new MessagingTestServer(8093);
    Header header = null;
    if (noticeError) {
        NewRelic.noticeError(new RuntimeException("I am something"));
    }
    try {
        server.start();
        header = runTestMessagingAPI();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        server.stop();
    }
    return header;
}
Also used : Transaction(com.newrelic.agent.Transaction) Header(org.apache.http.Header) MessagingTestServer(test.newrelic.test.agent.api.MessagingTestServer) IOException(java.io.IOException) DistributedTracePayloadImpl(com.newrelic.agent.tracing.DistributedTracePayloadImpl)

Aggregations

Transaction (com.newrelic.agent.Transaction)1 DistributedTracePayloadImpl (com.newrelic.agent.tracing.DistributedTracePayloadImpl)1 IOException (java.io.IOException)1 Header (org.apache.http.Header)1 MessagingTestServer (test.newrelic.test.agent.api.MessagingTestServer)1