Search in sources :

Example 6 with TransactionTrace

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

the class CassandraTest method testBatchStatementInsideSimpleStatement.

@Test
public void testBatchStatementInsideSimpleStatement() {
    demoBatchStatementInsideSimpleStatement();
    waitForSegmentEnd();
    DatastoreHelper helper = new DatastoreHelper(CASSANDRA_PRODUCT);
    helper.assertAggregateMetrics();
    helper.assertUnscopedOperationMetricCount("BATCH", 1);
    Collection<String> transactionNames = InstrumentationTestRunner.getIntrospector().getTransactionNames();
    assertEquals(1, transactionNames.size());
    String txName = transactionNames.iterator().next();
    helper.assertScopedOperationMetricCount(txName, "BATCH", 1);
    Collection<TransactionTrace> traces = InstrumentationTestRunner.getIntrospector().getTransactionTracesForTransaction(txName);
    assertEquals(1, traces.size());
    TransactionTrace trace = Iterables.getFirst(traces, null);
    assertNotNull(trace);
    assertBatchStatementInsideSimpleStatementTraceSegmentAttributes(trace);
}
Also used : TransactionTrace(com.newrelic.agent.introspec.TransactionTrace) 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 7 with TransactionTrace

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

the class CassandraTest method testAddListener.

@Test
public void testAddListener() throws Exception {
    ResultSet rs = addListernerTest().get();
    ExecutionInfo executionInfo = rs.getExecutionInfo();
    QueryTrace queryTrace = executionInfo.getQueryTrace();
    assertEquals(1, InstrumentationTestRunner.getIntrospector().getFinishedTransactionCount(30000));
    DatastoreHelper help = new DatastoreHelper(CASSANDRA_PRODUCT);
    help.assertAggregateMetrics();
    help.assertUnscopedOperationMetricCount("BATCH", 1);
    Collection<String> transactionNames = InstrumentationTestRunner.getIntrospector().getTransactionNames();
    String Txname = transactionNames.iterator().next();
    help.assertScopedOperationMetricCount(Txname, "BATCH", 1);
    Float databaseTime = MetricsHelper.getScopedMetricExclusiveTimeInSec(Txname, help.getOperationMetricName("BATCH"));
    Double timeDiff = ((databaseTime * 1000.0) - ((queryTrace.getDurationMicros()) / 1000.0));
    assertTrue("Database time includes the user callbacks.", timeDiff < 15);
    assertTrue("No time was captured for database.", databaseTime > 0);
    Collection<TransactionTrace> traces = InstrumentationTestRunner.getIntrospector().getTransactionTracesForTransaction(Txname);
    assertEquals(1, traces.size());
    TransactionTrace trace = Iterables.getFirst(traces, null);
    assertNotNull(trace);
    assertListenerTraceSegmentAttributes(trace);
}
Also used : ResultSet(com.datastax.driver.core.ResultSet) TransactionTrace(com.newrelic.agent.introspec.TransactionTrace) ExecutionInfo(com.datastax.driver.core.ExecutionInfo) QueryTrace(com.datastax.driver.core.QueryTrace) 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 8 with TransactionTrace

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

the class CassandraTest method testBasicWrapped.

@Test
public void testBasicWrapped() {
    demoBasicWrapped();
    assertEquals(1, InstrumentationTestRunner.getIntrospector().getFinishedTransactionCount(1000));
    Collection<String> transactionNames = InstrumentationTestRunner.getIntrospector().getTransactionNames();
    assertEquals(1, transactionNames.size());
    String txName = transactionNames.iterator().next();
    DatastoreHelper helper = new DatastoreHelper(CASSANDRA_PRODUCT);
    helper.assertScopedStatementMetricCount(txName, "INSERT", "users", 1);
    helper.assertScopedStatementMetricCount(txName, "SELECT", "users", 3);
    helper.assertScopedStatementMetricCount(txName, "UPDATE", "users", 1);
    helper.assertScopedStatementMetricCount(txName, "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);
    Collection<TransactionTrace> traces = InstrumentationTestRunner.getIntrospector().getTransactionTracesForTransaction(txName);
    assertEquals(1, traces.size());
    TransactionTrace trace = Iterables.getFirst(traces, null);
    assertNotNull(trace);
    assertBasicTraceSegmentAttributes(trace);
}
Also used : TransactionTrace(com.newrelic.agent.introspec.TransactionTrace) 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 9 with TransactionTrace

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

the class CassandraTest method testBatchStatement.

@Test
public void testBatchStatement() {
    demoBatchStatement();
    waitForSegmentEnd();
    DatastoreHelper helper = new DatastoreHelper(CASSANDRA_PRODUCT);
    helper.assertAggregateMetrics();
    helper.assertUnscopedOperationMetricCount("BATCH", 1);
    Collection<String> transactionNames = InstrumentationTestRunner.getIntrospector().getTransactionNames();
    assertEquals(1, transactionNames.size());
    String txName = transactionNames.iterator().next();
    helper.assertScopedOperationMetricCount(txName, "BATCH", 1);
    Collection<TransactionTrace> traces = InstrumentationTestRunner.getIntrospector().getTransactionTracesForTransaction(txName);
    assertEquals(1, traces.size());
    TransactionTrace trace = Iterables.getFirst(traces, null);
    assertNotNull(trace);
    assertBatchStatementTraceSegmentAttributes(trace);
}
Also used : TransactionTrace(com.newrelic.agent.introspec.TransactionTrace) 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 10 with TransactionTrace

use of com.newrelic.agent.introspec.TransactionTrace 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)

Aggregations

TransactionTrace (com.newrelic.agent.introspec.TransactionTrace)33 Test (org.junit.Test)27 TraceSegment (com.newrelic.agent.introspec.TraceSegment)24 Introspector (com.newrelic.agent.introspec.Introspector)23 TransactionEvent (com.newrelic.agent.introspec.TransactionEvent)15 Java16IncompatibleTest (com.newrelic.test.marker.Java16IncompatibleTest)12 Java17IncompatibleTest (com.newrelic.test.marker.Java17IncompatibleTest)12 ExternalRequest (com.newrelic.agent.introspec.ExternalRequest)10 DatastoreHelper (com.newrelic.agent.introspec.DatastoreHelper)7 URI (java.net.URI)7 Java10IncompatibleTest (com.newrelic.test.marker.Java10IncompatibleTest)6 Java11IncompatibleTest (com.newrelic.test.marker.Java11IncompatibleTest)6 Java12IncompatibleTest (com.newrelic.test.marker.Java12IncompatibleTest)6 Java13IncompatibleTest (com.newrelic.test.marker.Java13IncompatibleTest)6 Java14IncompatibleTest (com.newrelic.test.marker.Java14IncompatibleTest)6 Java15IncompatibleTest (com.newrelic.test.marker.Java15IncompatibleTest)6 Java7IncompatibleTest (com.newrelic.test.marker.Java7IncompatibleTest)6 Java9IncompatibleTest (com.newrelic.test.marker.Java9IncompatibleTest)6 TracedMetricData (com.newrelic.agent.introspec.TracedMetricData)4 CountDownLatch (java.util.concurrent.CountDownLatch)4