use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method statusCodeLastPolicy.
@Test
public void statusCodeLastPolicy() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.setStatus(404);
dispatcher.setStatus(200);
Assert.assertEquals(200, dispatcher.getStatus());
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method noRequestXQueueHeaders.
@Test
public void noRequestXQueueHeaders() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
Assert.assertEquals(0, dispatcher.getQueueTime());
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method apdexFrustrating.
@Test
public void apdexFrustrating() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.setStatus(200);
dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
Assert.assertFalse(dispatcher.isApdexFrustrating());
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method createDispatcher.
private WebRequestDispatcher createDispatcher(Request httpRequest) throws Exception {
Transaction tx = Transaction.getTransaction();
Response httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
DefaultTracer tracer = new OtherRootTracer(tx, sig, this, new SimpleMetricNameFormat("test"));
tx.getTransactionActivity().tracerStarted(tracer);
WebRequestDispatcher dispatcher = new WebRequestDispatcher(httpRequest, httpResponse, tx);
tx.setDispatcher(dispatcher);
return dispatcher;
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method requestXQueueStartHeaderNanoMagnitude.
@Test
public void requestXQueueStartHeaderNanoMagnitude() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
long nowInNanos = TimeUnit.NANOSECONDS.convert(Transaction.getTransaction().getWallClockStartTimeMs(), TimeUnit.MILLISECONDS);
long queueStartTimeInNanos = nowInNanos - 100000000l;
httpRequest.setHeader(QueueTimeTracker.REQUEST_X_QUEUE_START_HEADER, "t=" + queueStartTimeInNanos);
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
long queueStartTimeInMilliseconds = TimeUnit.MILLISECONDS.convert(queueStartTimeInNanos, TimeUnit.NANOSECONDS);
long expectedQueueTime = dispatcher.getTransaction().getWallClockStartTimeMs() - queueStartTimeInMilliseconds;
assertDelta(expectedQueueTime, dispatcher.getQueueTime(), 1);
}
Aggregations