use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class AttributeValidatorTest method createDispatcherTracer.
private BasicRequestRootTracer createDispatcherTracer() {
Transaction tx = Transaction.getTransaction();
MockHttpRequest httpRequest = new MockHttpRequest();
MockHttpResponse httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
return new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class RPMServiceTest method doForceRestartException.
private void doForceRestartException() throws Exception {
MockDataSenderFactory dataSenderFactory = new MockDataSenderFactory();
DataSenderFactory.setDataSenderFactory(dataSenderFactory);
Transaction.clearTransaction();
List<String> appNames = singletonList("MyApplication");
RPMService svc = new RPMService(appNames, null, null, Collections.<AgentConnectionEstablishedListener>emptyList());
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "test", "()V");
Tracer rootTracer = new BasicRequestRootTracer(Transaction.getTransaction(), sig, this, null, null, new SimpleMetricNameFormat("/test"));
AgentConfig iAgentConfig = mock(AgentConfig.class);
TransactionData data = new TransactionDataTestBuilder("unittest", iAgentConfig, rootTracer).setRequestUri("/unittest").build();
List<TransactionTrace> traces = singletonList(TransactionTrace.getTransactionTrace(data));
MockDataSender dataSender = dataSenderFactory.getLastDataSender();
dataSender.setConnected(false);
dataSender.setException(new ForceRestartException(""));
CountDownLatch latch = new CountDownLatch(1);
dataSender.setLatch(latch);
try {
svc.sendTransactionTraceData(traces);
} finally {
latch.await(10, TimeUnit.SECONDS);
assertTrue(dataSender.isConnected());
}
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class RPMServiceTest method doTestTransactionTraces.
private void doTestTransactionTraces() throws Exception {
MockDataSenderFactory dataSenderFactory = new MockDataSenderFactory();
DataSenderFactory.setDataSenderFactory(dataSenderFactory);
Transaction.clearTransaction();
List<String> appNames = singletonList("MyApplication");
RPMService svc = new RPMService(appNames, null, null, Collections.<AgentConnectionEstablishedListener>emptyList());
svc.launch();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "test", "()V");
Tracer rootTracer = new BasicRequestRootTracer(Transaction.getTransaction(), sig, this, null, null, new SimpleMetricNameFormat("/test"));
AgentConfig iAgentConfig = mock(AgentConfig.class);
TransactionData data = new TransactionDataTestBuilder("unittest", iAgentConfig, rootTracer).setRequestUri("/unittest").build();
List<TransactionTrace> traces = singletonList(TransactionTrace.getTransactionTrace(data));
try {
System.err.println("Transaction trace. JSON: " + DataSenderWriter.toJSONString(traces));
svc.sendTransactionTraceData(traces);
} catch (Exception e) {
System.err.println("Error sending transaction trace. JSON: " + DataSenderWriter.toJSONString(traces));
throw e;
}
assertEquals(traces, dataSenderFactory.getLastDataSender().getTraces());
svc.shutdown();
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class TransactionAsyncUtility method createAndStartDispatcherTracer.
public static BasicRequestRootTracer createAndStartDispatcherTracer(Object thisObj, String methodName, MockHttpRequest httpRequest) {
Transaction tx = Transaction.getTransaction();
MockHttpResponse httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(thisObj.getClass().getName(), methodName, "()V");
BasicRequestRootTracer brrt = new BasicRequestRootTracer(tx, sig, thisObj, httpRequest, httpResponse);
tx.getTransactionActivity().tracerStarted(brrt);
tx.setDispatcher(brrt.createDispatcher());
return brrt;
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class TransactionAsyncUtility method createDispatcherTracer.
// Create a Tracer for tests that require one.
public static BasicRequestRootTracer createDispatcherTracer(Object thisObj, String methodName) {
Transaction tx = Transaction.getTransaction();
MockHttpRequest httpRequest = new MockHttpRequest();
MockHttpResponse httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(thisObj.getClass().getName(), methodName, "()V");
BasicRequestRootTracer brrt = new BasicRequestRootTracer(tx, sig, thisObj, httpRequest, httpResponse);
tx.setDispatcher(brrt.createDispatcher());
return brrt;
}
Aggregations