Search in sources :

Example 41 with DatastoreHelper

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

the class DynamoApiTest method testPutAndGetItem.

@Test
public void testPutAndGetItem() {
    putAndGetTxn();
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    assertEquals(1, introspector.getFinishedTransactionCount(10000));
    String txName = introspector.getTransactionNames().iterator().next();
    DatastoreHelper helper = new DatastoreHelper(DYNAMODB_PRODUCT);
    helper.assertScopedStatementMetricCount(txName, "putItem", TABLE_NAME, 1);
    helper.assertScopedStatementMetricCount(txName, "getItem", TABLE_NAME, 1);
    helper.assertAggregateMetrics();
    helper.assertInstanceLevelMetric(DYNAMODB_PRODUCT, hostName, port);
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Test(org.junit.Test)

Example 42 with DatastoreHelper

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

the class DynamoApiTest method testUpdateItem.

@Test
public void testUpdateItem() {
    putItem();
    UpdateItemResult result = updateItemTxn();
    assertNotNull(result);
    Map<String, AttributeValue> item = getItem().getItem();
    AttributeValue attr = item.get("rating");
    assertNotNull(attr);
    assertEquals("{S: 5 stars,}", attr.toString());
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    assertEquals(1, introspector.getFinishedTransactionCount(10000));
    String txName = introspector.getTransactionNames().iterator().next();
    DatastoreHelper helper = new DatastoreHelper(DYNAMODB_PRODUCT);
    helper.assertScopedStatementMetricCount(txName, "updateItem", "test", 1);
    helper.assertAggregateMetrics();
    helper.assertInstanceLevelMetric(DYNAMODB_PRODUCT, hostName, port);
}
Also used : AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue) Introspector(com.newrelic.agent.introspec.Introspector) UpdateItemResult(com.amazonaws.services.dynamodbv2.model.UpdateItemResult) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Test(org.junit.Test)

Example 43 with DatastoreHelper

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

the class DynamoApiTest method testBadGetAsync.

@Test
public void testBadGetAsync() {
    getOrCreateTable(TABLE_NAME);
    getWrongItemAsyncTxn();
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    assertEquals(1, introspector.getFinishedTransactionCount(10000));
    String txName = introspector.getTransactionNames().iterator().next();
    Collection<TransactionEvent> transactionEvents = introspector.getTransactionEvents(txName);
    TransactionEvent event = transactionEvents.iterator().next();
    Map<String, Object> attributes = event.getAttributes();
    assertEquals(5, attributes.get("Miley Cyrus is not jazz"));
    assertEquals(100, attributes.get("Mingus is totally jazz"));
    DatastoreHelper helper = new DatastoreHelper(DYNAMODB_PRODUCT);
    helper.assertScopedStatementMetricCount(txName, "getItem", "test", 2);
    helper.assertAggregateMetrics();
    helper.assertInstanceLevelMetric(DYNAMODB_PRODUCT, hostName, port);
}
Also used : TransactionEvent(com.newrelic.agent.introspec.TransactionEvent) Introspector(com.newrelic.agent.introspec.Introspector) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Test(org.junit.Test)

Example 44 with DatastoreHelper

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

the class DynamoApiTest method testBatchWrite.

@Test
public void testBatchWrite() {
    getOrCreateTable(TABLE_NAME);
    getOrCreateTable(SECOND_TABLE_NAME);
    batchWriteTxn();
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    assertEquals(1, introspector.getFinishedTransactionCount(10000));
    String txName = introspector.getTransactionNames().iterator().next();
    DatastoreHelper helper = new DatastoreHelper(DYNAMODB_PRODUCT);
    helper.assertScopedStatementMetricCount(txName, "batchWriteItem", "batch", 1);
    helper.assertAggregateMetrics();
    helper.assertInstanceLevelMetric(DYNAMODB_PRODUCT, hostName, port);
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Test(org.junit.Test)

Example 45 with DatastoreHelper

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

the class DynamoApiTest method testBatchGetAsync.

@Test
public void testBatchGetAsync() throws ExecutionException, InterruptedException {
    getOrCreateTable(TABLE_NAME);
    batchGetAsyncTxn();
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    assertEquals(1, introspector.getFinishedTransactionCount(10000));
    String txName = introspector.getTransactionNames().iterator().next();
    DatastoreHelper helper = new DatastoreHelper(DYNAMODB_PRODUCT);
    helper.assertScopedStatementMetricCount(txName, "batchGetItem", "batch", 1);
    helper.assertAggregateMetrics();
    helper.assertInstanceLevelMetric(DYNAMODB_PRODUCT, hostName, port);
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) 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