Search in sources :

Example 1 with Introspector

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

the class CassandraTest method testCancelFuture.

@Test
public void testCancelFuture() {
    ResultSetFuture future = demoCancelFuture();
    assertTrue("The future is not executed completely", future.isDone());
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    assertEquals(1, introspector.getFinishedTransactionCount(1000));
    Collection<String> transactionNames = InstrumentationTestRunner.getIntrospector().getTransactionNames();
    assertEquals(1, transactionNames.size());
    String txName = transactionNames.iterator().next();
    DatastoreHelper help = new DatastoreHelper(CASSANDRA_PRODUCT);
    help.assertScopedOperationMetricCount(txName, "BATCH", 1);
    Collection<TransactionTrace> traces = InstrumentationTestRunner.getIntrospector().getTransactionTracesForTransaction(txName);
    assertEquals(1, traces.size());
    TransactionTrace trace = Iterables.getFirst(traces, null);
    assertNotNull(trace);
    assertCancelFutureTraceSegmentAttributes(trace);
}
Also used : ResultSetFuture(com.datastax.driver.core.ResultSetFuture) TransactionTrace(com.newrelic.agent.introspec.TransactionTrace) Introspector(com.newrelic.agent.introspec.Introspector) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Java16IncompatibleTest(com.newrelic.test.marker.Java16IncompatibleTest) Java17IncompatibleTest(com.newrelic.test.marker.Java17IncompatibleTest) Test(org.junit.Test) Java7IncompatibleTest(com.newrelic.test.marker.Java7IncompatibleTest)

Example 2 with Introspector

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

the class CassandraInstrumented method testAsyncRequestError.

@Test
public void testAsyncRequestError() {
    // Given
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    // When
    CassandraTestUtils.asyncRequestError(cassandra.session);
    // Then
    assertEquals(1, introspector.getFinishedTransactionCount(1000));
    assertEquals(1, introspector.getErrors().size());
    assertEquals(1, introspector.getErrorEvents().size());
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) Java10IncompatibleTest(com.newrelic.test.marker.Java10IncompatibleTest) Java13IncompatibleTest(com.newrelic.test.marker.Java13IncompatibleTest) Java16IncompatibleTest(com.newrelic.test.marker.Java16IncompatibleTest) Java9IncompatibleTest(com.newrelic.test.marker.Java9IncompatibleTest) Java17IncompatibleTest(com.newrelic.test.marker.Java17IncompatibleTest) Java14IncompatibleTest(com.newrelic.test.marker.Java14IncompatibleTest) Test(org.junit.Test) Java11IncompatibleTest(com.newrelic.test.marker.Java11IncompatibleTest) Java15IncompatibleTest(com.newrelic.test.marker.Java15IncompatibleTest) Java12IncompatibleTest(com.newrelic.test.marker.Java12IncompatibleTest) Java18IncompatibleTest(com.newrelic.test.marker.Java18IncompatibleTest)

Example 3 with Introspector

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

the class CassandraInstrumented method testSyncStatementRequests.

@Test
public void testSyncStatementRequests() {
    // Given
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    DatastoreHelper helper = new DatastoreHelper(DatastoreVendor.Cassandra.toString());
    // When
    CassandraTestUtils.statementRequests(cassandra.session);
    // 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);
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Java10IncompatibleTest(com.newrelic.test.marker.Java10IncompatibleTest) Java13IncompatibleTest(com.newrelic.test.marker.Java13IncompatibleTest) Java16IncompatibleTest(com.newrelic.test.marker.Java16IncompatibleTest) Java9IncompatibleTest(com.newrelic.test.marker.Java9IncompatibleTest) Java17IncompatibleTest(com.newrelic.test.marker.Java17IncompatibleTest) Java14IncompatibleTest(com.newrelic.test.marker.Java14IncompatibleTest) Test(org.junit.Test) Java11IncompatibleTest(com.newrelic.test.marker.Java11IncompatibleTest) Java15IncompatibleTest(com.newrelic.test.marker.Java15IncompatibleTest) Java12IncompatibleTest(com.newrelic.test.marker.Java12IncompatibleTest) Java18IncompatibleTest(com.newrelic.test.marker.Java18IncompatibleTest)

Example 4 with Introspector

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

the class CassandraInstrumented method testSyncBatchStatementRequests.

@Test
public void testSyncBatchStatementRequests() {
    // Given
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    DatastoreHelper helper = new DatastoreHelper(DatastoreVendor.Cassandra.toString());
    // When
    CassandraTestUtils.batchStatementRequests(cassandra.session);
    // Then
    assertEquals(1, introspector.getFinishedTransactionCount(1000));
    assertEquals(1, introspector.getTransactionNames().size());
    String transactionName = introspector.getTransactionNames().stream().findFirst().orElse("");
    Collection<TransactionTrace> traces = introspector.getTransactionTracesForTransaction(transactionName);
    List<TraceSegment> traceSegments = traces.stream().findFirst().map(TransactionTrace::getInitialTraceSegment).map(TraceSegment::getChildren).orElse(Collections.emptyList());
    helper.assertScopedOperationMetricCount(transactionName, "BATCH", 1);
    helper.assertAggregateMetrics();
    helper.assertUnscopedOperationMetricCount("BATCH", 1);
    assertEquals(1, traces.size());
    assertEquals(1, traceSegments.size());
    traceSegments.stream().map(TraceSegment::getTracerAttributes).forEach(x -> {
        assertNotNull(x.get("host"));
        assertNotNull(x.get("port_path_or_id"));
        assertNotNull(x.get("db.instance"));
    });
}
Also used : TransactionTrace(com.newrelic.agent.introspec.TransactionTrace) Introspector(com.newrelic.agent.introspec.Introspector) TraceSegment(com.newrelic.agent.introspec.TraceSegment) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Java10IncompatibleTest(com.newrelic.test.marker.Java10IncompatibleTest) Java13IncompatibleTest(com.newrelic.test.marker.Java13IncompatibleTest) Java16IncompatibleTest(com.newrelic.test.marker.Java16IncompatibleTest) Java9IncompatibleTest(com.newrelic.test.marker.Java9IncompatibleTest) Java17IncompatibleTest(com.newrelic.test.marker.Java17IncompatibleTest) Java14IncompatibleTest(com.newrelic.test.marker.Java14IncompatibleTest) Test(org.junit.Test) Java11IncompatibleTest(com.newrelic.test.marker.Java11IncompatibleTest) Java15IncompatibleTest(com.newrelic.test.marker.Java15IncompatibleTest) Java12IncompatibleTest(com.newrelic.test.marker.Java12IncompatibleTest) Java18IncompatibleTest(com.newrelic.test.marker.Java18IncompatibleTest)

Example 5 with Introspector

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

the class CassandraInstrumented method testAsyncBasicRequests.

@Test
public void testAsyncBasicRequests() {
    // Given
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    DatastoreHelper helper = new DatastoreHelper(DatastoreVendor.Cassandra.toString());
    // When
    CassandraTestUtils.asyncBasicRequests(cassandra.session);
    // Then
    assertEquals(1, introspector.getFinishedTransactionCount(1000));
    assertEquals(1, introspector.getTransactionNames().size());
    String transactionName = introspector.getTransactionNames().stream().findFirst().orElse("");
    helper.assertScopedStatementMetricCount(transactionName, "SELECT", "users", 2);
    helper.assertAggregateMetrics();
    helper.assertUnscopedOperationMetricCount("SELECT", 2);
    helper.assertUnscopedStatementMetricCount("SELECT", "users", 2);
}
Also used : Introspector(com.newrelic.agent.introspec.Introspector) DatastoreHelper(com.newrelic.agent.introspec.DatastoreHelper) Java10IncompatibleTest(com.newrelic.test.marker.Java10IncompatibleTest) Java13IncompatibleTest(com.newrelic.test.marker.Java13IncompatibleTest) Java16IncompatibleTest(com.newrelic.test.marker.Java16IncompatibleTest) Java9IncompatibleTest(com.newrelic.test.marker.Java9IncompatibleTest) Java17IncompatibleTest(com.newrelic.test.marker.Java17IncompatibleTest) Java14IncompatibleTest(com.newrelic.test.marker.Java14IncompatibleTest) Test(org.junit.Test) Java11IncompatibleTest(com.newrelic.test.marker.Java11IncompatibleTest) Java15IncompatibleTest(com.newrelic.test.marker.Java15IncompatibleTest) Java12IncompatibleTest(com.newrelic.test.marker.Java12IncompatibleTest) Java18IncompatibleTest(com.newrelic.test.marker.Java18IncompatibleTest)

Aggregations

Introspector (com.newrelic.agent.introspec.Introspector)436 Test (org.junit.Test)416 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)53 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