Search in sources :

Example 1 with DataStoreRequest

use of com.newrelic.agent.introspec.DataStoreRequest 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());
        }
    }
}
Also used : TransactionStats(com.newrelic.agent.stats.TransactionStats) DataStoreRequest(com.newrelic.agent.introspec.DataStoreRequest) Test(org.junit.Test)

Example 2 with DataStoreRequest

use of com.newrelic.agent.introspec.DataStoreRequest 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());
        }
    }
}
Also used : TransactionStats(com.newrelic.agent.stats.TransactionStats) DataStoreRequest(com.newrelic.agent.introspec.DataStoreRequest) Test(org.junit.Test)

Example 3 with DataStoreRequest

use of com.newrelic.agent.introspec.DataStoreRequest in project newrelic-java-agent by newrelic.

the class DatastoreForTransactionTest method testAddDatastoresTwoCallsSameMetrics.

@Test
public void testAddDatastoresTwoCallsSameMetrics() {
    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/statement/mysql/table/select").recordResponseTime(10, TimeUnit.MILLISECONDS);
    exts.addDatastore(true, stats);
    Collection<DataStoreRequest> actual = exts.getDatastores();
    Assert.assertEquals(1, actual.size());
    Iterator<DataStoreRequest> it = actual.iterator();
    DatastoreRequestImpl impl = (DatastoreRequestImpl) it.next();
    Assert.assertEquals(2, impl.getCount());
}
Also used : TransactionStats(com.newrelic.agent.stats.TransactionStats) DataStoreRequest(com.newrelic.agent.introspec.DataStoreRequest) Test(org.junit.Test)

Aggregations

DataStoreRequest (com.newrelic.agent.introspec.DataStoreRequest)3 TransactionStats (com.newrelic.agent.stats.TransactionStats)3 Test (org.junit.Test)3