use of com.newrelic.agent.introspec.DatastoreHelper in project newrelic-java-agent by newrelic.
the class MongoDbAsync360Test 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 MongoDbAsync3110Test 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 MongoDbAsync340Test 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 = 10;
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 MySQLInstrumentedTest method testParametrizedRequests.
@Test
public void testParametrizedRequests() {
// Given
Introspector introspector = InstrumentationTestRunner.getIntrospector();
DatastoreHelper helper = new DatastoreHelper("MySQL");
// When
R2dbcTestUtils.parametrizedRequests(connection);
// Then
assertEquals(1, introspector.getFinishedTransactionCount(1000));
assertEquals(1, introspector.getTransactionNames().size());
String transactionName = introspector.getTransactionNames().stream().findFirst().orElse("");
helper.assertScopedStatementMetricCount(transactionName, "INSERT", "USERS", 1);
helper.assertScopedStatementMetricCount(transactionName, "SELECT", "USERS", 3);
helper.assertScopedStatementMetricCount(transactionName, "UPDATE", "USERS", 1);
helper.assertScopedStatementMetricCount(transactionName, "DELETE", "USERS", 1);
helper.assertAggregateMetrics();
helper.assertUnscopedOperationMetricCount("INSERT", 1);
helper.assertUnscopedOperationMetricCount("SELECT", 3);
helper.assertUnscopedOperationMetricCount("UPDATE", 1);
helper.assertUnscopedOperationMetricCount("DELETE", 1);
helper.assertUnscopedStatementMetricCount("INSERT", "USERS", 1);
helper.assertUnscopedStatementMetricCount("SELECT", "USERS", 3);
helper.assertUnscopedStatementMetricCount("UPDATE", "USERS", 1);
helper.assertUnscopedStatementMetricCount("DELETE", "USERS", 1);
}
use of com.newrelic.agent.introspec.DatastoreHelper in project newrelic-java-agent by newrelic.
the class H2NoInstrumentationTest method testSelect.
@Test
public void testSelect() {
// Given
Introspector introspector = InstrumentationTestRunner.getIntrospector();
DatastoreHelper helper = new DatastoreHelper(DatastoreVendor.H2.toString());
// When
R2dbcTestUtils.basicRequests(connection);
// Then
assertEquals(1, introspector.getFinishedTransactionCount(1000));
assertEquals(1, introspector.getTransactionNames().size());
String transactionName = introspector.getTransactionNames().stream().findFirst().orElse("");
helper.assertScopedStatementMetricCount(transactionName, "INSERT", "USERS", 0);
helper.assertScopedStatementMetricCount(transactionName, "SELECT", "USERS", 0);
helper.assertScopedStatementMetricCount(transactionName, "UPDATE", "USERS", 0);
helper.assertScopedStatementMetricCount(transactionName, "DELETE", "USERS", 0);
}
Aggregations