use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.
the class ExternalAsyncTest method verifyCpu.
@Override
public void verifyCpu(long minCpu) {
super.verifyCpu(minCpu);
Collection<Tracer> tracers = data.getTracers();
for (Tracer current : tracers) {
if (current instanceof TransactionActivityInitiator) {
TransactionActivity txa = current.getTransactionActivity();
if (txa.getRootTracer().getAgentAttribute("async_context").equals(ASYNC_TXA_NAME)) {
Assert.assertEquals("External calls should have zero CPU time", 0L, txa.getTotalCpuTime());
}
}
}
}
use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.
the class ExternalsForTransactionTest method testcheckExternalsTwo.
@Test
public void testcheckExternalsTwo() {
// web
TransactionStats stats = new TransactionStats();
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/myhost/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("External/myhost/mylib").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/all").recordResponseTime(5, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/allWeb").recordResponseTime(5, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/secondhost/all").recordResponseTime(5, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("External/secondhost/secondlib").recordResponseTime(5, TimeUnit.MILLISECONDS);
Collection<Tracer> tracers = new ArrayList<>();
tracers.add(createTracer("External/myhost/mylib", "External/myhost/mylib/myOp"));
tracers.add(createTracer("External/secondhost/secondlib", "External/secondhost/secondlib/secondOp"));
Collection<ExternalRequestImpl> actual = ExternalsForTransaction.checkExternals(true, stats, tracers);
Assert.assertEquals(2, actual.size());
Iterator<ExternalRequestImpl> it = actual.iterator();
while (it.hasNext()) {
ExternalRequestImpl impl = it.next();
Assert.assertEquals(1, impl.getCount());
if (impl.getMetricName().equals("External/myhost/mylib")) {
Assert.assertEquals("myhost", impl.getHostname());
Assert.assertEquals("mylib", impl.getLibrary());
Assert.assertEquals("myOp", impl.getOperation());
} else {
Assert.assertEquals("secondhost", impl.getHostname());
Assert.assertEquals("secondlib", impl.getLibrary());
Assert.assertEquals("secondOp", impl.getOperation());
}
}
// other
stats = new TransactionStats();
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/allOther").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/myhost/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("External/myhost/mylib").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/all").recordResponseTime(5, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/allOther").recordResponseTime(5, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/secondhost/all").recordResponseTime(5, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("External/secondhost/secondlib").recordResponseTime(5, TimeUnit.MILLISECONDS);
tracers = new ArrayList<>();
tracers.add(createTracer("External/myhost/mylib", "External/myhost/mylib/myOp"));
tracers.add(createTracer("External/secondhost/secondlib", "External/secondhost/secondlib/secondOp"));
actual = ExternalsForTransaction.checkExternals(false, stats, tracers);
Assert.assertEquals(2, actual.size());
it = actual.iterator();
while (it.hasNext()) {
ExternalRequestImpl impl = it.next();
Assert.assertEquals(1, impl.getCount());
if (impl.getMetricName().equals("External/myhost/mylib")) {
Assert.assertEquals("myhost", impl.getHostname());
Assert.assertEquals("mylib", impl.getLibrary());
Assert.assertEquals("myOp", impl.getOperation());
} else {
Assert.assertEquals("secondhost", impl.getHostname());
Assert.assertEquals("secondlib", impl.getLibrary());
Assert.assertEquals("secondOp", impl.getOperation());
}
}
}
use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.
the class ExternalsForTransactionTest method testAddExternalsOneCall.
@Test
public void testAddExternalsOneCall() {
TransactionStats stats = new TransactionStats();
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/myhost/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("External/myhost/mylib").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/all").recordResponseTime(5, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/allWeb").recordResponseTime(5, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/myhost/all").recordResponseTime(5, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("External/myhost/secondlib").recordResponseTime(5, TimeUnit.MILLISECONDS);
Collection<Tracer> tracers = new ArrayList<>();
tracers.add(createTracer("External/myhost/mylib", "External/myhost/mylib/myop"));
tracers.add(createTracer("External/myhost/secondlib", "External/myhost/secondlib/seconop"));
ExternalsForTransaction exts = new ExternalsForTransaction();
exts.addExternals(true, stats, tracers);
Collection<ExternalRequest> actual = exts.getExternals();
Assert.assertEquals(2, actual.size());
Iterator<ExternalRequest> it = actual.iterator();
while (it.hasNext()) {
ExternalRequestImpl impl = (ExternalRequestImpl) it.next();
Assert.assertEquals(1, impl.getCount());
if (impl.getMetricName().equals("External/myhost/mylib")) {
Assert.assertEquals("myhost", impl.getHostname());
Assert.assertEquals("mylib", impl.getLibrary());
Assert.assertEquals("myop", impl.getOperation());
} else {
Assert.assertEquals("myhost", impl.getHostname());
Assert.assertEquals("secondlib", impl.getLibrary());
Assert.assertEquals("seconop", impl.getOperation());
}
}
}
use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.
the class ExternalsForTransactionTest method testcheckExternalsOne.
@Test
public void testcheckExternalsOne() {
// web
TransactionStats stats = new TransactionStats();
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/myhost/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("External/myhost/mylib").recordResponseTime(10, TimeUnit.MILLISECONDS);
Collection<Tracer> tracers = new ArrayList<>();
tracers.add(createTracer("External/myhost/mylib", "External/myhost/mylib/myOp"));
Collection<ExternalRequestImpl> actual = ExternalsForTransaction.checkExternals(true, stats, tracers);
Assert.assertEquals(1, actual.size());
ExternalRequestImpl impl = actual.iterator().next();
Assert.assertEquals(1, impl.getCount());
Assert.assertEquals("myhost", impl.getHostname());
Assert.assertEquals("mylib", impl.getLibrary());
Assert.assertEquals("myOp", impl.getOperation());
// other
stats = new TransactionStats();
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/allOther").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/myhost/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("External/myhost/mylib").recordResponseTime(10, TimeUnit.MILLISECONDS);
tracers = new ArrayList<>();
tracers.add(createTracer("External/myhost/mylib", "External/myhost/mylib/myOp"));
actual = ExternalsForTransaction.checkExternals(false, stats, tracers);
Assert.assertEquals(1, actual.size());
impl = actual.iterator().next();
Assert.assertEquals(1, impl.getCount());
Assert.assertEquals("myhost", impl.getHostname());
Assert.assertEquals("mylib", impl.getLibrary());
Assert.assertEquals("myOp", impl.getOperation());
}
use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.
the class ExternalsForTransactionTest method testAddExternalsTwoCallsSameOperation.
@Test
public void testAddExternalsTwoCallsSameOperation() {
TransactionStats stats = new TransactionStats();
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/myhost/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("External/myhost/mylib").recordResponseTime(10, TimeUnit.MILLISECONDS);
Collection<Tracer> tracers = new ArrayList<>();
tracers.add(createTracer("External/myhost/mylib", "External/myhost/mylib/myop"));
ExternalsForTransaction exts = new ExternalsForTransaction();
exts.addExternals(true, stats, tracers);
stats = new TransactionStats();
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("External/myhost/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("External/myhost/mylib").recordResponseTime(10, TimeUnit.MILLISECONDS);
tracers = new ArrayList<>();
tracers.add(createTracer("External/myhost/mylib", "External/myhost/mylib/myop"));
exts.addExternals(true, stats, tracers);
Collection<ExternalRequest> actual = exts.getExternals();
Assert.assertEquals(1, actual.size());
Iterator<ExternalRequest> it = actual.iterator();
while (it.hasNext()) {
ExternalRequestImpl impl = (ExternalRequestImpl) it.next();
Assert.assertEquals(2, impl.getCount());
Assert.assertEquals("myhost", impl.getHostname());
Assert.assertEquals("mylib", impl.getLibrary());
Assert.assertEquals("myop", impl.getOperation());
}
}
Aggregations