use of com.newrelic.agent.stats.StatsBase in project newrelic-java-agent by newrelic.
the class TransactionAsyncRootLastTest method verifyDataTwo.
private void verifyDataTwo(StartAndThenLink activity, Transaction tx, TokenImpl token) {
waitForTransaction();
TransactionAsyncUtility.basicDataVerify(data, stats, activity, 2);
Map<String, StatsBase> scoped = stats.getScopedStats().getStatsMap();
ResponseTimeStats data1 = (ResponseTimeStats) scoped.get("RequestDispatcher");
ResponseTimeStats data2 = (ResponseTimeStats) scoped.get("Java/java.lang.Object/root" + token.toString());
Assert.assertNotNull(data1);
Assert.assertNotNull(data2);
Assert.assertEquals(1, data1.getCallCount());
Assert.assertEquals(1, data2.getCallCount());
Map<String, StatsBase> unscoped = stats.getUnscopedStats().getStatsMap();
Assert.assertEquals(((ResponseTimeStats) unscoped.get("WebTransactionTotalTime")).getTotal(), data1.getTotal() + data2.getTotal(), .001);
}
use of com.newrelic.agent.stats.StatsBase in project newrelic-java-agent by newrelic.
the class InstrumentTestUtils method getAndClearMetricData.
public static Map<String, Integer> getAndClearMetricData() {
StatsEngine statsEngine = AgentHelper.getDefaultStatsEngine();
List<MetricData> data = statsEngine.getMetricData(new MockNormalizer());
Map<String, Integer> dataMap = new HashMap<>();
for (MetricData metricData : data) {
StatsBase stats = metricData.getStats();
if (stats instanceof CountStats) {
dataMap.put(metricData.getMetricName().getName(), ((CountStats) stats).getCallCount());
} else {
dataMap.put(metricData.getMetricName().getName(), 0);
}
}
return dataMap;
}
use of com.newrelic.agent.stats.StatsBase in project newrelic-java-agent by newrelic.
the class ExternalsForTransaction method checkExternals.
protected static Collection<ExternalRequestImpl> checkExternals(boolean isWeb, TransactionStats stats, Collection<Tracer> tracers) {
int totalCount = 0;
// External/all
// External/allWeb or External/allOther
Multimap<String, ExternalRequestImpl> currentExternalsByHost = HashMultimap.create();
Map<String, StatsBase> theStats = stats.getScopedStats().getStatsMap();
String segment;
String metric;
for (Tracer current : tracers) {
segment = current.getTransactionSegmentName();
metric = current.getMetricName();
if (metric.startsWith("External") && theStats.get(metric) != null) {
ExternalRequestImpl impl = ExternalRequestImpl.checkAndMakeExternal(current);
if (impl != null) {
currentExternalsByHost.put(impl.getHostname(), impl);
totalCount++;
}
}
}
return currentExternalsByHost.values();
}
use of com.newrelic.agent.stats.StatsBase in project newrelic-java-agent by newrelic.
the class TransactionAsyncEdgeCaseTest method testLinkSameThreadAfterWorkFinishes.
@Test
public void testLinkSameThreadAfterWorkFinishes() throws InterruptedException {
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "outer-hi");
tx.getTransactionActivity().tracerStarted(rootTracer);
TokenImpl token = (TokenImpl) tx.getToken();
Tracer defaultTracer = TransactionAsyncUtility.createDefaultTracer("mymethod1");
tx.getTransactionActivity().tracerStarted(defaultTracer);
defaultTracer.finish(Opcodes.RETURN, 0);
rootTracer.finish(Opcodes.RETURN, 0);
Transaction.clearTransaction();
TransactionActivity.clear();
TransactionActivity.create(null, 0);
rootTracer = TransactionAsyncUtility.createOtherTracer("inner-hi");
TransactionActivity.get().tracerStarted(rootTracer);
Assert.assertTrue(Transaction.linkTxOnThread(token));
defaultTracer = TransactionAsyncUtility.createDefaultTracer("mymethod2");
tx.getTransactionActivity().tracerStarted(defaultTracer);
token.expire();
defaultTracer.finish(Opcodes.RETURN, 0);
rootTracer.finish(Opcodes.RETURN, 0);
waitForTransaction();
Assert.assertNotNull(data);
Assert.assertNotNull(stats);
Assert.assertEquals(2, data.getTransactionActivities().size());
Collection<Tracer> tracers = data.getTracers();
Assert.assertEquals(4, tracers.size() + 1);
Assert.assertEquals("RequestDispatcher", data.getRootTracer().getMetricName());
Map<String, StatsBase> metrics = stats.getScopedStats().getStatsMap();
ResponseTimeStatsImpl sb = (ResponseTimeStatsImpl) metrics.get("Custom/mymethod1");
Assert.assertEquals(1, sb.getCallCount());
sb = (ResponseTimeStatsImpl) metrics.get("Custom/mymethod2");
Assert.assertEquals(1, sb.getCallCount());
sb = (ResponseTimeStatsImpl) metrics.get("Java/java.lang.Object/inner-hi");
Assert.assertEquals(1, sb.getCallCount());
sb = (ResponseTimeStatsImpl) metrics.get("RequestDispatcher");
Assert.assertEquals(1, sb.getCallCount());
}
Aggregations