Search in sources :

Example 46 with DatastoreHelper

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

the class DefaultDynamoDbClient_InstrumentationTest method assertOperation.

private void assertOperation(String operation) {
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    assertEquals(1, introspector.getFinishedTransactionCount(DEFAULT_TIMEOUT_IN_MILLIS));
    String txName = introspector.getTransactionNames().iterator().next();
    DatastoreHelper helper = new DatastoreHelper(DYNAMODB_PRODUCT);
    helper.assertAggregateMetrics();
    helper.assertScopedOperationMetricCount(txName, operation, 1);
    helper.assertInstanceLevelMetric(DYNAMODB_PRODUCT, dynamoDb.getHostName(), dynamoDb.getPort());
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper)

Example 47 with DatastoreHelper

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

the class MongoDb212Test method testFindAndModify.

@Test
public void testFindAndModify() throws Exception {
    demoFindAndModify(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, "findandmodify", "pokemon", 1);
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Test(org.junit.Test)

Example 48 with DatastoreHelper

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

the class MongoDb212Test method testBulkOps.

@Test
public void testBulkOps() throws Exception {
    demoBulkOps(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", 3);
    helper.assertUnifiedMetricCounts(txName, "parallelCollectionScan", "pokemon", 1);
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Test(org.junit.Test)

Example 49 with DatastoreHelper

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

the class MongoDb212Test method testAggregation.

@Test
public void testAggregation() throws Exception {
    demoAggregation(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, "aggregate", "pokemon", 2);
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Test(org.junit.Test)

Example 50 with DatastoreHelper

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

the class Lettuce43InstrumentationTest 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.lettuce43.instrumentation.helper.RedisDataService/asyncSet";
    String getTransactionName = "OtherTransaction/Custom/com.nr.lettuce43.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());
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) Data(com.nr.lettuce43.instrumentation.helper.Data) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Test(org.junit.Test)

Aggregations

DatastoreHelper (com.newrelic.agent.introspec.DatastoreHelper)74 Test (org.junit.Test)72 Introspector (com.newrelic.agent.introspec.Introspector)69 Java16IncompatibleTest (com.newrelic.test.marker.Java16IncompatibleTest)11 Java17IncompatibleTest (com.newrelic.test.marker.Java17IncompatibleTest)11 ConnectionString (com.mongodb.ConnectionString)9 Java7IncompatibleTest (com.newrelic.test.marker.Java7IncompatibleTest)8 TransactionTrace (com.newrelic.agent.introspec.TransactionTrace)7 Java10IncompatibleTest (com.newrelic.test.marker.Java10IncompatibleTest)5 Java11IncompatibleTest (com.newrelic.test.marker.Java11IncompatibleTest)5 Java12IncompatibleTest (com.newrelic.test.marker.Java12IncompatibleTest)5 Java13IncompatibleTest (com.newrelic.test.marker.Java13IncompatibleTest)5 Java14IncompatibleTest (com.newrelic.test.marker.Java14IncompatibleTest)5 Java15IncompatibleTest (com.newrelic.test.marker.Java15IncompatibleTest)5 Java18IncompatibleTest (com.newrelic.test.marker.Java18IncompatibleTest)5 Java9IncompatibleTest (com.newrelic.test.marker.Java9IncompatibleTest)5 Ignore (org.junit.Ignore)3 Data (com.nr.lettuce5.instrumentation.helper.Data)2 Data (com.nr.lettuce6.instrumentation.helper.Data)2 AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)1