Search in sources :

Example 11 with Introspector

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

the class Jersey2ClientTest method testAsyncCallback.

@Test
public void testAsyncCallback() throws Exception {
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    URI endpoint = server.getEndPoint();
    requestHttpMethodsAsyncCallback(endpoint.toString());
    // transaction
    String txName = "OtherTransaction/Custom/com.nr.agent.instrumentation.jerseyclient2.Jersey2ClientTest/requestHttpMethodsAsyncCallback";
    assertEquals(1, introspector.getFinishedTransactionCount(2000));
    Collection<String> names = introspector.getTransactionNames();
    assertTrue(names.contains(txName));
    // external request test should go here
    Collection<ExternalRequest> externalRequests = introspector.getExternalRequests(txName);
    assertEquals(1, externalRequests.size());
    assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/localhost/all"));
    assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/allOther"));
    assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/all"));
    assertEquals(1, MetricsHelper.getUnscopedMetricCount("IAmMetric"));
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) URI(java.net.URI) ExternalRequest(com.newrelic.agent.introspec.ExternalRequest) Test(org.junit.Test)

Example 12 with Introspector

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

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

Example 13 with Introspector

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

the class MongoDb310Test method testCollectionApi.

@Test
public void testCollectionApi() throws Exception {
    runQuickTour();
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    assertEquals(1, introspector.getFinishedTransactionCount(1000));
    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();
    helper.assertUnifiedMetricCounts(txName, "insert", "test", 4);
    helper.assertUnifiedMetricCounts(txName, "update", "test", 6);
    helper.assertUnifiedMetricCounts(txName, "delete", "test", 4);
    helper.assertUnifiedMetricCounts(txName, "find", "test", 13);
    helper.assertUnifiedMetricCounts(txName, "drop", "test", 3);
    helper.assertUnifiedMetricCounts(txName, "count", "test", 1);
    helper.assertUnifiedMetricCounts(txName, "getMore", "test", 12);
    assertEquals(44, MetricsHelper.getUnscopedMetricCount("Datastore/all"));
    assertEquals(44, (int) introspector.getTransactionEvents(txName).iterator().next().getDatabaseCallCount());
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Test(org.junit.Test)

Example 14 with Introspector

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

the class MongoDb300Test 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 15 with Introspector

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

the class MongoDb300Test 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)

Aggregations

Introspector (com.newrelic.agent.introspec.Introspector)452 Test (org.junit.Test)432 TransactionEvent (com.newrelic.agent.introspec.TransactionEvent)150 Java16IncompatibleTest (com.newrelic.test.marker.Java16IncompatibleTest)88 Java17IncompatibleTest (com.newrelic.test.marker.Java17IncompatibleTest)88 Java11IncompatibleTest (com.newrelic.test.marker.Java11IncompatibleTest)86 Java12IncompatibleTest (com.newrelic.test.marker.Java12IncompatibleTest)86 Java13IncompatibleTest (com.newrelic.test.marker.Java13IncompatibleTest)86 Java14IncompatibleTest (com.newrelic.test.marker.Java14IncompatibleTest)86 Java15IncompatibleTest (com.newrelic.test.marker.Java15IncompatibleTest)86 DatastoreHelper (com.newrelic.agent.introspec.DatastoreHelper)69 ExternalRequest (com.newrelic.agent.introspec.ExternalRequest)51 TracedMetricData (com.newrelic.agent.introspec.TracedMetricData)51 URI (java.net.URI)41 Java7IncompatibleTest (com.newrelic.test.marker.Java7IncompatibleTest)32 TransactionTrace (com.newrelic.agent.introspec.TransactionTrace)25 TraceSegment (com.newrelic.agent.introspec.TraceSegment)19 Matchers.containsString (org.hamcrest.Matchers.containsString)16 Java10IncompatibleTest (com.newrelic.test.marker.Java10IncompatibleTest)13 Java9IncompatibleTest (com.newrelic.test.marker.Java9IncompatibleTest)13