use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method testAutoAppNamingApdexT.
@Test
public void testAutoAppNamingApdexT() throws Exception {
Map<String, Object> configMap = createConfigMap(0);
// Configuring this in the newrelic.yml file is deprecated.
// This is mocking a server side config property we get on connect.
configMap.put(AgentConfigImpl.APDEX_T, 0.001f);
createServiceManager(AgentConfigImpl.createAgentConfig(configMap), configMap);
MockHttpRequest httpRequest = new MockHttpRequest();
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
// App name is something other than APP_NAME = "Unit Test"
dispatcher.getTransaction().setApplicationName(ApplicationNamePriority.SERVLET_INIT_PARAM, "SecondAppName");
dispatcher.transactionFinished("WebTransaction/transactionName", new TransactionStats());
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method requestXStartHeader.
@Test
public void requestXStartHeader() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
long nowInMicroseconds = TimeUnit.MICROSECONDS.convert(Transaction.getTransaction().getWallClockStartTimeMs(), TimeUnit.MILLISECONDS);
long requestStartTimeInMicroseconds = nowInMicroseconds - 10000;
httpRequest.setHeader(QueueTimeTracker.REQUEST_X_START_HEADER, "server1 t=" + requestStartTimeInMicroseconds);
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
long requestStartTimeInMilliseconds = TimeUnit.MILLISECONDS.convert(requestStartTimeInMicroseconds, TimeUnit.MICROSECONDS);
long expectedExternalTime = dispatcher.getTransaction().getWallClockStartTimeMs() - requestStartTimeInMilliseconds;
long actualExternalTime = dispatcher.getQueueTime();
assertDelta(expectedExternalTime, actualExternalTime, 1);
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method statusCodePolicyProperty.
@Test
public void statusCodePolicyProperty() throws Exception {
ServiceManager old = ServiceFactory.getServiceManager();
Map<String, Object> configMap = createConfigMap(0);
configMap.put(HiddenProperties.LAST_STATUS_CODE_POLICY, false);
createServiceManager(AgentConfigImpl.createAgentConfig(configMap), configMap);
MockHttpRequest httpRequest = new MockHttpRequest();
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.setStatus(404);
dispatcher.setStatus(200);
Assert.assertEquals(404, dispatcher.getStatus());
ServiceFactory.getServiceManager().stop();
ServiceFactory.setServiceManager(old);
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method testReferrer.
@Test
public void testReferrer() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
httpRequest.setHeader("Referer", "HelloThere!");
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
Assert.assertNull(Transaction.getTransaction().getAgentAttributes().get(AttributeNames.REQUEST_REFERER_PARAMETER_NAME));
dispatcher.transactionActivityWithResponseFinished();
Assert.assertEquals("HelloThere!", Transaction.getTransaction().getAgentAttributes().get(AttributeNames.REQUEST_REFERER_PARAMETER_NAME));
}
use of com.newrelic.agent.dispatchers.WebRequestDispatcher in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method requestXStartHeaderFractionalSecondsMagnitude.
@Test
public void requestXStartHeaderFractionalSecondsMagnitude() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
double nowInSeconds = TimeConversion.convertMillisToSeconds(Transaction.getTransaction().getWallClockStartTimeMs());
double queueStartTimeInSeconds = nowInSeconds - 10;
httpRequest.setHeader(QueueTimeTracker.REQUEST_X_START_HEADER, String.format("t=%1$.3f", queueStartTimeInSeconds));
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.transactionFinished("WebTransaction/Uri/test", stats);
assertDelta(10000, dispatcher.getQueueTime(), 1);
}
Aggregations