use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method requestXQueueStartHeader.
@Test
public void requestXQueueStartHeader() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
long nowInMicroseconds = TimeUnit.MICROSECONDS.convert(Transaction.getTransaction().getWallClockStartTimeMs(), TimeUnit.MILLISECONDS);
long queueStartTimeInMicroseconds = nowInMicroseconds - 10000;
httpRequest.setHeader(QueueTimeTracker.REQUEST_X_QUEUE_START_HEADER, "t=" + queueStartTimeInMicroseconds);
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
long queueStartTimeInMilliseconds = TimeUnit.MILLISECONDS.convert(queueStartTimeInMicroseconds, TimeUnit.MICROSECONDS);
long expectedQueueTime = dispatcher.getTransaction().getWallClockStartTimeMs() - queueStartTimeInMilliseconds;
assertDelta(expectedQueueTime, dispatcher.getQueueTime(), 1);
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method referrerHeaderRecorded1.
@Test
public void referrerHeaderRecorded1() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
httpRequest.setHeader("Referer", "http://example.com:80?myparam=test&secret=donttell");
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
Transaction tx = Transaction.getTransaction();
dispatcher.setStatus(500);
dispatcher.transactionActivityWithResponseFinished();
dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
Assert.assertTrue("Referer header should be captured", ((String) tx.getAgentAttributes().get(AttributeNames.REQUEST_REFERER_PARAMETER_NAME)).contains("example.com"));
Assert.assertFalse("Referer header shouldn't include url parameters", ((String) tx.getAgentAttributes().get(AttributeNames.REQUEST_REFERER_PARAMETER_NAME)).contains("donttell"));
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method requestXStartHeaderNanoMagnitude.
@Test
public void requestXStartHeaderNanoMagnitude() 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_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);
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method requestXQueueStartHeaderNegativeValue.
@Test
public void requestXQueueStartHeaderNegativeValue() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
long queueStartTimeInMillis = (Transaction.getTransaction().getWallClockStartTimeMs() - 100) * -1;
httpRequest.setHeader(QueueTimeTracker.REQUEST_X_QUEUE_START_HEADER, "t=" + queueStartTimeInMillis);
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 statusCodeFreezePolicy.
@Test
public void statusCodeFreezePolicy() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.setStatus(404);
dispatcher.freezeStatus();
dispatcher.setStatus(200);
Assert.assertEquals(404, dispatcher.getStatus());
}
Aggregations