use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method testHttpMethod.
@Test
public void testHttpMethod() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
httpRequest.setMethod("POST");
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.getTransaction().getTransactionActivity().markAsResponseSender();
dispatcher.getTransaction().getRootTracer().finish(0, null);
dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
Map<String, Object> agentAttributes = dispatcher.getTransaction().getAgentAttributes();
assertEquals("POST", agentAttributes.get(AttributeNames.REQUEST_METHOD_PARAMETER_NAME));
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method requestXQueueStartHeaderMilliMagnitude.
@Test
public void requestXQueueStartHeaderMilliMagnitude() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
long nowInMillis = Transaction.getTransaction().getWallClockStartTimeMs();
long queueStartTimeInMillis = nowInMillis - 10;
httpRequest.setHeader(QueueTimeTracker.REQUEST_X_QUEUE_START_HEADER, "t=" + queueStartTimeInMillis);
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
long expectedQueueTime = dispatcher.getTransaction().getWallClockStartTimeMs() - queueStartTimeInMillis;
assertDelta(expectedQueueTime, dispatcher.getQueueTime(), 1);
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method statusCodeNoMetric.
@Test
public void statusCodeNoMetric() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
Transaction tx = Transaction.getTransaction();
dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
Assert.assertEquals(0, dispatcher.getStatus());
Assert.assertEquals(0, tx.getStatus());
String spec = "Network/Inbound/StatusCode/0";
Assert.assertEquals(0, tx.getTransactionActivity().getTransactionStats().getUnscopedStats().getOrCreateResponseTimeStats(spec).getCallCount());
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method requestXStartHeaderRecordMetricsBadValue.
@Test
public void requestXStartHeaderRecordMetricsBadValue() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
httpRequest.setHeader(QueueTimeTracker.REQUEST_X_START_HEADER, "server1 t=cafebabe");
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
TransactionStats statsEngine = new TransactionStats();
dispatcher.recordHeaderMetrics(statsEngine);
Assert.assertEquals(0, statsEngine.getSize());
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method statusCodeTxaDone.
@Test
public void statusCodeTxaDone() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.setStatus(404);
dispatcher.transactionActivityWithResponseFinished();
dispatcher.setStatus(200);
Assert.assertEquals(404, dispatcher.getStatus());
}
Aggregations