use of com.newrelic.agent.introspec.DatastoreHelper in project newrelic-java-agent by newrelic.
the class Lettuce6InstrumentationTest method testSync.
@Test
public void testSync() {
// given some data
String key = "syncKey";
String value = "syncValue";
// when sync 'set' called
String response = redisDataService.syncSet(key, value);
// then response should be key
assertEquals("Then response should be key", key, response);
// when 'get' called
String received = redisDataService.syncGet(key);
// then value returned
assertEquals("Get value", value, received);
// and 2 transactions have been sent
Introspector introspector = InstrumentationTestRunner.getIntrospector();
assertEquals("Finished transaction count", 2, introspector.getFinishedTransactionCount(1000));
Collection<String> transactionNames = introspector.getTransactionNames();
assertEquals("Transaction name count", 2, transactionNames.size());
String setTransactionName = "OtherTransaction/Custom/com.nr.lettuce6.instrumentation.helper.RedisDataService/syncSet";
String getTransactionName = "OtherTransaction/Custom/com.nr.lettuce6.instrumentation.helper.RedisDataService/syncGet";
// and transaction names are in collection
assertTrue("Should contain transaction name for 'set'", transactionNames.contains(setTransactionName));
assertTrue("Should contain transaction name for 'get'", transactionNames.contains(getTransactionName));
// and required datastore metrics are sent
DatastoreHelper helper = new DatastoreHelper(DatastoreVendor.Redis.name());
helper.assertAggregateMetrics();
assertEquals(1, introspector.getTransactionEvents(setTransactionName).iterator().next().getDatabaseCallCount());
assertEquals(1, introspector.getTransactionEvents(getTransactionName).iterator().next().getDatabaseCallCount());
helper.assertUnscopedOperationMetricCount("SET", 1);
helper.assertUnscopedOperationMetricCount("GET", 1);
helper.assertInstanceLevelMetric(DatastoreVendor.Redis.name(), redis.getHost(), redis.getFirstMappedPort().toString());
}
use of com.newrelic.agent.introspec.DatastoreHelper in project newrelic-java-agent by newrelic.
the class Lettuce6InstrumentationTest method testAsync.
@Test
public void testAsync() throws ExecutionException, InterruptedException {
// given some data
Data data = new Data("asyncKey1", "asyncValue1");
// when async 'set' called
String response = redisDataService.asyncSet(data);
// then response should be 'OK'
assertEquals("Then response should be 'OK'", "OK", response);
// when async 'get' called
String value = redisDataService.asyncGet(data.key);
// then value returned
assertEquals("Get value", data.value, value);
// and 2 transactions have been sent
Introspector introspector = InstrumentationTestRunner.getIntrospector();
assertEquals("Finished transaction count", 2, introspector.getFinishedTransactionCount(1000));
Collection<String> transactionNames = introspector.getTransactionNames();
assertEquals("Transaction name count", 2, transactionNames.size());
String setTransactionName = "OtherTransaction/Custom/com.nr.lettuce6.instrumentation.helper.RedisDataService/asyncSet";
String getTransactionName = "OtherTransaction/Custom/com.nr.lettuce6.instrumentation.helper.RedisDataService/asyncGet";
// and transaction names are in collection
assertTrue("Should contain transaction name for 'set'", transactionNames.contains(setTransactionName));
assertTrue("Should contain transaction name for 'get'", transactionNames.contains(getTransactionName));
// and required datastore metrics are sent
DatastoreHelper helper = new DatastoreHelper("Redis");
helper.assertAggregateMetrics();
assertEquals(1, introspector.getTransactionEvents(setTransactionName).iterator().next().getDatabaseCallCount());
assertEquals(1, introspector.getTransactionEvents(getTransactionName).iterator().next().getDatabaseCallCount());
helper.assertUnscopedOperationMetricCount("SET", 1);
helper.assertUnscopedOperationMetricCount("GET", 1);
helper.assertInstanceLevelMetric(DatastoreVendor.Redis.name(), redis.getHost(), redis.getFirstMappedPort().toString());
}
use of com.newrelic.agent.introspec.DatastoreHelper in project newrelic-java-agent by newrelic.
the class Lettuce5InstrumentationTest method testSync.
@Test
public void testSync() {
// given some data
String key = "syncKey";
String value = "syncValue";
// when sync 'set' called
String response = redisDataService.syncSet(key, value);
// then response should be key
assertEquals("Then response should be key", key, response);
// when 'get' called
String received = redisDataService.syncGet(key);
// then value returned
assertEquals("Get value", value, received);
// and 2 transactions have been sent
Introspector introspector = InstrumentationTestRunner.getIntrospector();
assertEquals("Finished transaction count", 2, introspector.getFinishedTransactionCount(1000));
Collection<String> transactionNames = introspector.getTransactionNames();
assertEquals("Transaction name count", 2, transactionNames.size());
String setTransactionName = "OtherTransaction/Custom/com.nr.lettuce5.instrumentation.helper.RedisDataService/syncSet";
String getTransactionName = "OtherTransaction/Custom/com.nr.lettuce5.instrumentation.helper.RedisDataService/syncGet";
// and transaction names are in collection
assertTrue("Should contain transaction name for 'set'", transactionNames.contains(setTransactionName));
assertTrue("Should contain transaction name for 'get'", transactionNames.contains(getTransactionName));
// and required datastore metrics are sent
DatastoreHelper helper = new DatastoreHelper(DatastoreVendor.Redis.name());
helper.assertAggregateMetrics();
assertEquals(1, introspector.getTransactionEvents(setTransactionName).iterator().next().getDatabaseCallCount());
assertEquals(1, introspector.getTransactionEvents(getTransactionName).iterator().next().getDatabaseCallCount());
helper.assertUnscopedOperationMetricCount("SET", 1);
helper.assertUnscopedOperationMetricCount("GET", 1);
helper.assertInstanceLevelMetric(DatastoreVendor.Redis.name(), redis.getHost(), redis.getFirstMappedPort().toString());
}
use of com.newrelic.agent.introspec.DatastoreHelper in project newrelic-java-agent by newrelic.
the class MongoDb310Test method testBulkOps.
@Test
public void testBulkOps() throws Exception {
demoBulkOps(new PokemonMaster(mongoClient));
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();
helper.assertUnifiedMetricCounts(txName, "insert", "pokemon", 3);
helper.assertUnifiedMetricCounts(txName, "parallelCollectionScan", "pokemon", 1);
}
use of com.newrelic.agent.introspec.DatastoreHelper in project newrelic-java-agent by newrelic.
the class MongoDb310Test method testAggregation.
@Test
public void testAggregation() throws Exception {
demoAggregation(new PokemonMaster(mongoClient));
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();
helper.assertUnifiedMetricCounts(txName, "aggregate", "pokemon", 2);
}
Aggregations