use of com.newrelic.agent.introspec.DatastoreHelper in project newrelic-java-agent by newrelic.
the class MongoDb214Test method testCRUD.
@Test
public void testCRUD() throws Exception {
demoCRUD(new PokemonMaster(mongoClient));
Introspector introspector = InstrumentationTestRunner.getIntrospector();
assertEquals(1, introspector.getFinishedTransactionCount());
DatastoreHelper helper = new DatastoreHelper(MONGODB_PRODUCT);
helper.assertAggregateMetrics();
Collection<String> transactionNames = InstrumentationTestRunner.getIntrospector().getTransactionNames();
assertEquals(1, transactionNames.size());
String txName = transactionNames.iterator().next();
helper.assertUnifiedMetricCounts(txName, "insert", "pokemon", 1);
helper.assertUnifiedMetricCounts(txName, "find", "pokemon", 2);
helper.assertUnifiedMetricCounts(txName, "update", "pokemon", 1);
helper.assertUnifiedMetricCounts(txName, "remove", "pokemon", 1);
}
use of com.newrelic.agent.introspec.DatastoreHelper in project newrelic-java-agent by newrelic.
the class MongoDb300Test method testCollectionApi.
@Test
public void testCollectionApi() throws Exception {
runQuickTour();
Introspector introspector = InstrumentationTestRunner.getIntrospector();
assertEquals(1, introspector.getFinishedTransactionCount());
DatastoreHelper helper = new DatastoreHelper(MONGODB_PRODUCT);
helper.assertAggregateMetrics();
// helper.assertUnscopedOperationMetricCount("dropDatabase", 1);
Collection<String> transactionNames = InstrumentationTestRunner.getIntrospector().getTransactionNames();
assertEquals(1, transactionNames.size());
String txName = transactionNames.iterator().next();
// 4
helper.assertUnifiedMetricCounts(txName, "insert", "test", 3);
// 6
helper.assertUnifiedMetricCounts(txName, "update", "test", 3);
helper.assertUnifiedMetricCounts(txName, "delete", "test", 4);
helper.assertUnifiedMetricCounts(txName, "find", "test", 13);
helper.assertUnifiedMetricCounts(txName, "drop", "test", 3);
helper.assertUnifiedMetricCounts(txName, "count", "test", 1);
// 12
helper.assertUnifiedMetricCounts(txName, "getMore", "test", 10);
helper.assertUnifiedMetricCounts(txName, "insertMany", "test", 1);
helper.assertUnifiedMetricCounts(txName, "updateMany", "test", 1);
helper.assertUnifiedMetricCounts(txName, "bulkWrite", "test", 2);
helper.assertUnifiedMetricCounts(txName, "other", "test", 2);
assertEquals(43, MetricsHelper.getUnscopedMetricCount("Datastore/all"));
assertEquals(43, (int) introspector.getTransactionEvents(txName).iterator().next().getDatabaseCallCount());
}
use of com.newrelic.agent.introspec.DatastoreHelper in project newrelic-java-agent by newrelic.
the class MongoDb300Test method testCRUD.
@Test
public void testCRUD() throws Exception {
demoCRUD(new PokemonMaster(mongoClient));
Introspector introspector = InstrumentationTestRunner.getIntrospector();
assertEquals(1, introspector.getFinishedTransactionCount());
DatastoreHelper helper = new DatastoreHelper(MONGODB_PRODUCT);
helper.assertAggregateMetrics();
Collection<String> transactionNames = InstrumentationTestRunner.getIntrospector().getTransactionNames();
assertEquals(1, transactionNames.size());
String txName = transactionNames.iterator().next();
helper.assertUnifiedMetricCounts(txName, "insert", "pokemon", 1);
helper.assertUnifiedMetricCounts(txName, "find", "pokemon", 2);
helper.assertUnifiedMetricCounts(txName, "update", "pokemon", 1);
helper.assertUnifiedMetricCounts(txName, "remove", "pokemon", 1);
assertEquals(5, MetricsHelper.getUnscopedMetricCount("Datastore/all"));
assertEquals(5, (int) introspector.getTransactionEvents(txName).iterator().next().getDatabaseCallCount());
}
use of com.newrelic.agent.introspec.DatastoreHelper in project newrelic-java-agent by newrelic.
the class MongoDbAsync3100Test method testCollectionApi.
@Test
public void testCollectionApi() throws Exception {
runMongoDbAsyncQuickStart();
Introspector introspector = InstrumentationTestRunner.getIntrospector();
assertEquals(1, introspector.getFinishedTransactionCount(1000));
DatastoreHelper helper = new DatastoreHelper(MONGODB_PRODUCT);
helper.assertAggregateMetrics();
Collection<String> transactionNames = InstrumentationTestRunner.getIntrospector().getTransactionNames();
assertEquals(1, transactionNames.size());
String txName = transactionNames.iterator().next();
// Counts based on operations executed in MongoDbAsyncQuickStart
int insertOpExpectedCount = 1;
int insertManyOpExpectedCount = 1;
int updateOpExpectedCount = 1;
int updateManyOpExpectedCount = 1;
int deleteOpExpectedCount = 1;
int deleteManyOpExpectedCount = 1;
int findOpExpectedCount = 14;
int dropOpExpectedCount = 3;
int countOpExpectedCount = 1;
int bulkWriteOpExpectedCount = 2;
helper.assertUnifiedMetricCounts(txName, "insert", "test", insertOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "insertMany", "test", insertManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "update", "test", updateOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "updateMany", "test", updateManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "delete", "test", deleteOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "deleteMany", "test", deleteManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "find", "test", findOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "drop", "test", dropOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "count", "test", countOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "bulkWrite", "test", bulkWriteOpExpectedCount);
int totalOpCount = insertOpExpectedCount + insertManyOpExpectedCount + updateOpExpectedCount + updateManyOpExpectedCount + deleteOpExpectedCount + deleteManyOpExpectedCount + findOpExpectedCount + dropOpExpectedCount + countOpExpectedCount + bulkWriteOpExpectedCount;
// Should be equal to the sum of all above metric counts
assertEquals(totalOpCount, MetricsHelper.getUnscopedMetricCount("Datastore/all"));
assertEquals(totalOpCount, MetricsHelper.getUnscopedMetricCount("Datastore/MongoDB/allOther"));
assertEquals(totalOpCount, introspector.getTransactionEvents(txName).iterator().next().getDatabaseCallCount());
}
use of com.newrelic.agent.introspec.DatastoreHelper in project newrelic-java-agent by newrelic.
the class MongoDbAsync400Test method testCollectionApi.
@Test
public void testCollectionApi() throws Exception {
runMongoQuickTour();
Introspector introspector = InstrumentationTestRunner.getIntrospector();
assertEquals(1, introspector.getFinishedTransactionCount(1000));
DatastoreHelper helper = new DatastoreHelper(MONGODB_PRODUCT);
helper.assertAggregateMetrics();
Collection<String> transactionNames = InstrumentationTestRunner.getIntrospector().getTransactionNames();
assertEquals(1, transactionNames.size());
String txName = transactionNames.iterator().next();
// Counts based on operations executed in QuickTour
int insertOpExpectedCount = 1;
int insertManyOpExpectedCount = 1;
int updateOpExpectedCount = 1;
int updateManyOpExpectedCount = 1;
int deleteOpExpectedCount = 1;
int deleteManyOpExpectedCount = 1;
int findOpExpectedCount = 8;
int dropOpExpectedCount = 2;
int countOpExpectedCount = 1;
int bulkWriteOpExpectedCount = 2;
int createIndexesOpExpectedCount = 1;
int unknownOpExpectedCount = 3;
helper.assertUnifiedMetricCounts(txName, "insert", "test", insertOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "insertMany", "test", insertManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "update", "test", updateOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "updateMany", "test", updateManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "delete", "test", deleteOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "deleteMany", "test", deleteManyOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "find", "test", findOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "drop", "test", dropOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "count", "test", countOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "bulkWrite", "test", bulkWriteOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "createIndexes", "test", createIndexesOpExpectedCount);
helper.assertUnifiedMetricCounts(txName, "Unknown", "Unknown", unknownOpExpectedCount);
int totalOpCount = insertOpExpectedCount + insertManyOpExpectedCount + updateOpExpectedCount + updateManyOpExpectedCount + deleteOpExpectedCount + deleteManyOpExpectedCount + findOpExpectedCount + dropOpExpectedCount + countOpExpectedCount + bulkWriteOpExpectedCount + createIndexesOpExpectedCount + unknownOpExpectedCount;
// Should be equal to the sum of all above metric counts
assertEquals(totalOpCount, MetricsHelper.getUnscopedMetricCount("Datastore/all"));
assertEquals(totalOpCount, MetricsHelper.getUnscopedMetricCount("Datastore/MongoDB/allOther"));
assertEquals(totalOpCount, introspector.getTransactionEvents(txName).iterator().next().getDatabaseCallCount());
}
Aggregations