use of com.newrelic.agent.stats.ResponseTimeStats 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.ResponseTimeStats in project newrelic-java-agent by newrelic.
the class RPMServiceTest method doHarvest.
private void doHarvest() throws Exception {
List<String> appNames = singletonList("MyApplication");
RPMService svc = new RPMService(appNames, null, null, Collections.<AgentConnectionEstablishedListener>emptyList());
svc.launch();
synchronized (this) {
wait(1000);
}
StatsEngine harvestStatsEngine = new StatsEngineImpl();
try {
for (int i = 0; i < 1000; i++) {
harvestStatsEngine.getResponseTimeStats(MetricNames.EXTERNAL_ALL).recordResponseTime(66, TimeUnit.MILLISECONDS);
}
svc.harvest(harvestStatsEngine);
Stats stats3 = harvestStatsEngine.getStats(MetricNames.AGENT_METRICS_COUNT);
assertEquals(0, stats3.getCallCount());
ResponseTimeStats stats = harvestStatsEngine.getResponseTimeStats(MetricNames.SUPPORTABILITY_METRIC_HARVEST_TRANSMIT);
assertEquals(1, stats.getCallCount());
assertTrue(stats.getTotal() > 0);
Stats stats2 = harvestStatsEngine.getStats(MetricNames.SUPPORTABILITY_METRIC_HARVEST_COUNT);
assertEquals(1, stats2.getCallCount());
} finally {
svc.shutdown();
}
}
use of com.newrelic.agent.stats.ResponseTimeStats in project newrelic-java-agent by newrelic.
the class SegmentTest method testMetricMigration.
@Test
public void testMetricMigration() throws InterruptedException {
Tracer root = makeTransaction();
Assert.assertNotNull(root);
Assert.assertNotNull(root.getTransactionActivity().getTransaction());
final Segment segment = root.getTransactionActivity().getTransaction().startSegment(MetricNames.CUSTOM, "Custom Segment");
segment.getTracedMethod().addRollupMetricName("rollupMetric");
segment.getTracedMethod().addExclusiveRollupMetricName("exclusiveRollupMetric");
segment.end();
root.finish(Opcodes.ARETURN, null);
assertTrue(root.getTransactionActivity().getTransaction().isFinished());
ResponseTimeStats rollupMetric = root.getTransactionActivity().getTransactionStats().getUnscopedStats().getOrCreateResponseTimeStats("rollupMetric");
assertTrue(rollupMetric.getCallCount() == 1);
ResponseTimeStats exclusiveRollupMetric = root.getTransactionActivity().getTransactionStats().getUnscopedStats().getOrCreateResponseTimeStats("exclusiveRollupMetric");
assertTrue(exclusiveRollupMetric.getCallCount() == 1);
}
use of com.newrelic.agent.stats.ResponseTimeStats in project newrelic-java-agent by newrelic.
the class TransactionDataList method getMetricCounts.
public Map<String, Integer> getMetricCounts(Set<MetricName> responseTimeMetricNames) {
Map<String, Integer> metricNameToCounts = new HashMap<>();
synchronized (statsEngine) {
for (MetricName responseTimeMetricName : responseTimeMetricNames) {
ResponseTimeStats responseTimeStats = statsEngine.getResponseTimeStats(responseTimeMetricName);
metricNameToCounts.put(responseTimeMetricName.getName(), responseTimeStats.getCallCount());
}
}
return metricNameToCounts;
}
use of com.newrelic.agent.stats.ResponseTimeStats in project newrelic-java-agent by newrelic.
the class DefaultTracer method recordMetrics.
/**
* Record response time metrics.
*/
protected void recordMetrics(TransactionStats transactionStats) {
try {
recordExternalMetrics();
} catch (Throwable t) {
String msg = MessageFormat.format("An error occurred recording external metrics for class {0} : {1}", classMethodSignature.getClassName(), t.toString());
Agent.LOG.severe(msg);
Agent.LOG.log(Level.FINER, msg, t);
}
if (getTransaction() == null || getTransaction().isIgnore()) {
return;
}
if (isMetricProducer()) {
String metricName = getMetricName();
if (metricName != null) {
// record the scoped metrics
ResponseTimeStats stats = transactionStats.getScopedStats().getOrCreateResponseTimeStats(metricName);
stats.recordResponseTimeInNanos(getDuration(), getExclusiveDuration());
// there is now an unscoped metric for every scoped metric
// the unscoped metric is created in the StatsEngineImpl
}
if (getRollupMetricNames() != null) {
for (String name : getRollupMetricNames()) {
ResponseTimeStats stats = transactionStats.getUnscopedStats().getOrCreateResponseTimeStats(name);
stats.recordResponseTimeInNanos(getDuration(), getExclusiveDuration());
}
}
if (getExclusiveRollupMetricNames() != null) {
for (String name : getExclusiveRollupMetricNames()) {
ResponseTimeStats stats = transactionStats.getUnscopedStats().getOrCreateResponseTimeStats(name);
stats.recordResponseTimeInNanos(getExclusiveDuration(), getExclusiveDuration());
}
}
doRecordMetrics(transactionStats);
}
}
Aggregations