use of com.newrelic.agent.stats.TransactionStats in project newrelic-java-agent by newrelic.
the class DatastoreForTransactionTest method testAddDatastoresTwoCalls.
@Test
public void testAddDatastoresTwoCalls() {
TransactionStats stats = new TransactionStats();
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("Datastore/statement/mysql/table/select").recordResponseTime(10, TimeUnit.MILLISECONDS);
DatastoreForTransaction exts = new DatastoreForTransaction();
exts.addDatastore(true, stats);
stats = new TransactionStats();
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("Datastore/operation/mysql/insert").recordResponseTime(10, TimeUnit.MILLISECONDS);
exts.addDatastore(true, stats);
Collection<DataStoreRequest> actual = exts.getDatastores();
Assert.assertEquals(2, actual.size());
Iterator<DataStoreRequest> it = actual.iterator();
while (it.hasNext()) {
DatastoreRequestImpl impl = (DatastoreRequestImpl) it.next();
Assert.assertEquals(1, impl.getCount());
if (impl.getMetricName().equals("Datastore/operation/mysql/insert")) {
Assert.assertEquals("mysql", impl.getDatastore());
Assert.assertEquals("insert", impl.getOperation());
} else {
Assert.assertEquals("mysql", impl.getDatastore());
Assert.assertEquals("table", impl.getTable());
Assert.assertEquals("select", impl.getOperation());
}
}
}
use of com.newrelic.agent.stats.TransactionStats in project newrelic-java-agent by newrelic.
the class DatastoreForTransactionTest method testcheckDatastoresOne.
@Test
public void testcheckDatastoresOne() {
// web
TransactionStats stats = new TransactionStats();
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("Datastore/statement/mysql/table/select").recordResponseTime(10, TimeUnit.MILLISECONDS);
Collection<DatastoreRequestImpl> actual = DatastoreForTransaction.checkDatastores(true, stats);
Assert.assertEquals(1, actual.size());
DatastoreRequestImpl impl = actual.iterator().next();
Assert.assertEquals(1, impl.getCount());
Assert.assertEquals("mysql", impl.getDatastore());
Assert.assertEquals("table", impl.getTable());
Assert.assertEquals("select", impl.getOperation());
// other
stats = new TransactionStats();
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/allOther").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/allOther").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("Datastore/statement/mysql/table/select").recordResponseTime(10, TimeUnit.MILLISECONDS);
actual = DatastoreForTransaction.checkDatastores(true, stats);
Assert.assertEquals(0, actual.size());
actual = DatastoreForTransaction.checkDatastores(false, stats);
Assert.assertEquals(1, actual.size());
impl = actual.iterator().next();
Assert.assertEquals(1, impl.getCount());
Assert.assertEquals("mysql", impl.getDatastore());
Assert.assertEquals("table", impl.getTable());
Assert.assertEquals("select", impl.getOperation());
}
use of com.newrelic.agent.stats.TransactionStats in project newrelic-java-agent by newrelic.
the class DatastoreForTransactionTest method testcheckDatastoresSameHost.
@Test
public void testcheckDatastoresSameHost() {
TransactionStats stats = new TransactionStats();
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("Datastore/statement/mysql/table/select").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("Datastore/operation/mysql/insert").recordResponseTime(10, TimeUnit.MILLISECONDS);
Collection<DatastoreRequestImpl> actual = DatastoreForTransaction.checkDatastores(true, stats);
Assert.assertEquals(2, actual.size());
Iterator<DatastoreRequestImpl> it = actual.iterator();
while (it.hasNext()) {
DatastoreRequestImpl impl = it.next();
Assert.assertEquals(1, impl.getCount());
if (impl.getMetricName().equals("Datastore/operation/mysql/insert")) {
Assert.assertEquals("mysql", impl.getDatastore());
Assert.assertEquals("insert", impl.getOperation());
} else {
Assert.assertEquals("mysql", impl.getDatastore());
Assert.assertEquals("table", impl.getTable());
Assert.assertEquals("select", impl.getOperation());
}
}
}
use of com.newrelic.agent.stats.TransactionStats in project newrelic-java-agent by newrelic.
the class DatastoreForTransactionTest method testAddDatastoresOneCall.
@Test
public void testAddDatastoresOneCall() {
TransactionStats stats = new TransactionStats();
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("Datastore/statement/mysql/table/select").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/all").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getUnscopedStats().getOrCreateResponseTimeStats("Datastore/mysql/allWeb").recordResponseTime(10, TimeUnit.MILLISECONDS);
stats.getScopedStats().getOrCreateResponseTimeStats("Datastore/operation/mysql/insert").recordResponseTime(10, TimeUnit.MILLISECONDS);
DatastoreForTransaction exts = new DatastoreForTransaction();
exts.addDatastore(true, stats);
Collection<DataStoreRequest> actual = exts.getDatastores();
Assert.assertEquals(2, actual.size());
Iterator<DataStoreRequest> it = actual.iterator();
while (it.hasNext()) {
DatastoreRequestImpl impl = (DatastoreRequestImpl) it.next();
Assert.assertEquals(1, impl.getCount());
if (impl.getMetricName().equals("Datastore/operation/mysql/insert")) {
Assert.assertEquals("mysql", impl.getDatastore());
Assert.assertEquals("insert", impl.getOperation());
} else {
Assert.assertEquals("mysql", impl.getDatastore());
Assert.assertEquals("table", impl.getTable());
Assert.assertEquals("select", impl.getOperation());
}
}
}
use of com.newrelic.agent.stats.TransactionStats 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());
}
}
}
Aggregations