use of com.newrelic.agent.stats.ApdexStats in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method apdexNotKeyTransaction.
@Test
public void apdexNotKeyTransaction() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
Transaction tx = Transaction.getTransaction();
dispatcher.setStatus(200);
dispatcher.transactionFinished("WebTransaction/Custom/UrlGenerator/ru/betting/Motorsport", tx.getTransactionActivity().getTransactionStats());
ApdexStats stats1 = tx.getTransactionActivity().getTransactionStats().getUnscopedStats().getApdexStats("Apdex/Custom/UrlGenerator/ru/betting/Motorsport");
ByteArrayOutputStream out = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(out);
stats1.writeJSONString(writer);
writer.close();
Assert.assertEquals("[1,0,0,0.5,0.5,0]", out.toString());
}
use of com.newrelic.agent.stats.ApdexStats in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method requestXQueueHeaderRecordApdexMetrics.
@Test
public void requestXQueueHeaderRecordApdexMetrics() throws Exception {
MockRPMServiceManager rpmServiceManager = (MockRPMServiceManager) ServiceFactory.getRPMServiceManager();
MockRPMService rpmService = (MockRPMService) rpmServiceManager.getRPMService();
rpmService.setEverConnected(true);
Map<String, Object> data = new HashMap<>();
data.put(AgentConfigImpl.APDEX_T, 6.0d);
ConnectionConfigListener connectionConfigListener = rpmServiceManager.getConnectionConfigListener();
connectionConfigListener.connected(rpmService, data);
MockHttpRequest httpRequest = new MockHttpRequest();
httpRequest.setHeader(QueueTimeTracker.REQUEST_X_START_HEADER, "server1 t=" + (Transaction.getTransaction().getWallClockStartTimeMs() - 23500));
httpRequest.setHeader(QueueTimeTracker.REQUEST_X_QUEUE_START_HEADER, "t=" + (Transaction.getTransaction().getWallClockStartTimeMs() - 23500));
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.getTransaction().getRootTracer().finish(0, null);
StatsEngine statsEngine = ServiceFactory.getStatsService().getStatsEngineForHarvest(APP_NAME);
ApdexStats apdexStats = statsEngine.getApdexStats(MetricName.create(MetricNames.APDEX));
Assert.assertEquals(0, apdexStats.getApdexFrustrating());
apdexStats = statsEngine.getApdexStats(MetricName.create("Apdex/Uri/Unknown"));
Assert.assertEquals(0, apdexStats.getApdexFrustrating());
}
use of com.newrelic.agent.stats.ApdexStats in project newrelic-java-agent by newrelic.
the class WebRequestDispatcher method recordApdexMetrics.
private void recordApdexMetrics(String frontendMetricName, TransactionStats stats) {
if (frontendMetricName == null || frontendMetricName.length() == 0) {
return;
}
if (!getTransaction().getAgentConfig().isApdexTSet()) {
return;
}
if (isIgnoreApdex()) {
Agent.LOG.log(Level.FINE, "Ignoring transaction for Apdex {0}", frontendMetricName);
return;
}
String frontendApdexMetricName = getApdexMetricName(frontendMetricName, MetricNames.WEB_TRANSACTION, MetricNames.APDEX);
if (frontendApdexMetricName == null || frontendApdexMetricName.length() == 0) {
return;
}
long apdexT = getTransaction().getAgentConfig().getApdexTInMillis(frontendMetricName);
ApdexStats apdexStats = stats.getUnscopedStats().getApdexStats(frontendApdexMetricName);
ApdexStats overallApdexStats = stats.getUnscopedStats().getApdexStats(MetricNames.APDEX);
if (isApdexFrustrating()) {
apdexStats.recordApdexFrustrated();
overallApdexStats.recordApdexFrustrated();
} else {
long responseTimeInMillis = getTransaction().getTransactionTimer().getResponseTimeInMilliseconds() + externalTimeTracker.getExternalTime();
apdexStats.recordApdexResponseTime(responseTimeInMillis, apdexT);
overallApdexStats.recordApdexResponseTime(responseTimeInMillis, apdexT);
}
}
use of com.newrelic.agent.stats.ApdexStats in project newrelic-java-agent by newrelic.
the class OtherDispatcher method recordApdexMetrics.
private void recordApdexMetrics(String transactionName, TransactionStats stats) {
if (transactionName == null || transactionName.length() == 0) {
return;
}
if (!getTransaction().getAgentConfig().isApdexTSet(transactionName)) {
return;
}
if (isIgnoreApdex()) {
Agent.LOG.log(Level.FINE, "Ignoring transaction for Apdex {0}", transactionName);
return;
}
String apdexMetricName = getApdexMetricName(transactionName, MetricNames.OTHER_TRANSACTION, MetricNames.APDEX_OTHER_TRANSACTION);
if (apdexMetricName == null || apdexMetricName.length() == 0) {
return;
}
long apdexT = getTransaction().getAgentConfig().getApdexTInMillis(transactionName);
ApdexStats apdexStats = stats.getUnscopedStats().getApdexStats(apdexMetricName);
ApdexStats overallApdexStats = stats.getUnscopedStats().getApdexStats(MetricNames.APDEX_OTHER);
if (isApdexFrustrating()) {
apdexStats.recordApdexFrustrated();
overallApdexStats.recordApdexFrustrated();
} else {
long responseTimeInMillis = getTransaction().getTransactionTimer().getResponseTimeInMilliseconds();
apdexStats.recordApdexResponseTime(responseTimeInMillis, apdexT);
overallApdexStats.recordApdexResponseTime(responseTimeInMillis, apdexT);
}
}
use of com.newrelic.agent.stats.ApdexStats in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method apdexKeyTransaction.
@Test
public void apdexKeyTransaction() throws Exception {
MockHttpRequest httpRequest = new MockHttpRequest();
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
Transaction tx = Transaction.getTransaction();
dispatcher.setStatus(200);
dispatcher.transactionFinished("WebTransaction/Custom/UrlGenerator/en/betting/Football", stats);
ApdexStats stats1 = stats.getUnscopedStats().getApdexStats("Apdex/Custom/UrlGenerator/en/betting/Football");
ByteArrayOutputStream out = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(out);
stats1.writeJSONString(writer);
writer.close();
Assert.assertEquals("[1,0,0,7.0,7.0,0]", out.toString());
}
Aggregations