Search in sources :

Example 16 with TransactionEvent

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

the class VertxBlockingTest method testBlocking.

@Test
public void testBlocking() throws InterruptedException {
    Vertx vertx = Vertx.vertx();
    try {
        executeBlocking(vertx);
        String expectedTxnName = "OtherTransaction/Custom/com.nr.vertx.instrumentation.VertxBlockingTest/executeBlocking";
        Introspector introspector = InstrumentationTestRunner.getIntrospector();
        assertEquals(1, introspector.getFinishedTransactionCount(500));
        TransactionEvent txnEvent = introspector.getTransactionEvents(expectedTxnName).iterator().next();
        Map<String, Object> attributes = txnEvent.getAttributes();
        assertTrue(attributes.containsKey("InFuture"));
        assertTrue(attributes.containsKey("InResponseHandler"));
    } finally {
        vertx.close();
    }
}
Also used : TransactionEvent(com.newrelic.agent.introspec.TransactionEvent) Introspector(com.newrelic.agent.introspec.Introspector) Vertx(io.vertx.core.Vertx) Test(org.junit.Test)

Example 17 with TransactionEvent

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

the class VertxClient method testCat.

@Test
public void testCat() throws Exception {
    try (HttpTestServer httpServer = HttpServerLocator.createAndStart()) {
        cat(httpServer);
        Introspector introspector = InstrumentationTestRunner.getIntrospector();
        String host = httpServer.getEndPoint().getHost();
        String txName = "OtherTransaction/Custom/com.nr.vertx.instrumentation.VertxClient/cat";
        assertEquals(2, introspector.getFinishedTransactionCount(250));
        Collection<String> names = introspector.getTransactionNames();
        assertEquals(2, names.size());
        assertTrue(names.contains(httpServer.getServerTransactionName()));
        assertTrue(names.contains(txName));
        // scoped metrics
        assertEquals(1, MetricsHelper.getScopedMetricCount(txName, "ExternalTransaction/" + host + "/" + httpServer.getCrossProcessId() + "/" + httpServer.getServerTransactionName()));
        assertEquals(1, MetricsHelper.getScopedMetricCount(txName, "Java/com.nr.vertx.instrumentation.VertxClient/cat"));
        // unscoped metrics
        assertEquals(1, MetricsHelper.getUnscopedMetricCount("ExternalTransaction/" + host + "/" + httpServer.getCrossProcessId() + "/" + httpServer.getServerTransactionName()));
        assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/" + host + "/all"));
        assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/all"));
        assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/allOther"));
        // events
        Collection<TransactionEvent> transactionEvents = introspector.getTransactionEvents(txName);
        assertEquals(1, transactionEvents.size());
        TransactionEvent transactionEvent = transactionEvents.iterator().next();
        assertEquals(1, transactionEvent.getExternalCallCount());
        assertTrue(transactionEvent.getExternalDurationInSec() > 0);
        CatHelper.verifyOneSuccessfulCat(introspector, txName);
        // external request information
        Collection<ExternalRequest> externalRequests = introspector.getExternalRequests(txName);
        assertEquals(1, externalRequests.size());
        ExternalRequest externalRequest = externalRequests.iterator().next();
        assertEquals(1, externalRequest.getCount());
        assertEquals(host, externalRequest.getHostname());
    }
}
Also used : TransactionEvent(com.newrelic.agent.introspec.TransactionEvent) Introspector(com.newrelic.agent.introspec.Introspector) HttpTestServer(com.newrelic.agent.introspec.HttpTestServer) ExternalRequest(com.newrelic.agent.introspec.ExternalRequest) Test(org.junit.Test)

Example 18 with TransactionEvent

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

the class VertxClient method assertExternal.

public void assertExternal(String transactionName, String host) {
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    Collection<ExternalRequest> externalRequests = introspector.getExternalRequests(transactionName);
    ExternalRequest request = externalRequests.iterator().next();
    assertEquals(host, request.getHostname());
    assertEquals("Vertx-Client", request.getLibrary());
    assertEquals("end", request.getOperation());
    Collection<TransactionEvent> events = introspector.getTransactionEvents(transactionName);
    TransactionEvent event = events.iterator().next();
    assertTrue(event.getAttributes().containsKey("responseHandler"));
    assertEquals(1, MetricsHelper.getScopedMetricCount(transactionName, "External/localhost/Vertx-Client/end"));
    assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/localhost/Vertx-Client/end"));
    Collection<TransactionEvent> transactionEvents = introspector.getTransactionEvents(transactionName);
    assertEquals(1, transactionEvents.size());
    TransactionEvent transactionEvent = transactionEvents.iterator().next();
    assertEquals(1, transactionEvent.getExternalCallCount());
    assertTrue(transactionEvent.getExternalDurationInSec() > 0);
    // external rollups
    assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/localhost/all"));
    assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/allOther"));
    assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/all"));
}
Also used : TransactionEvent(com.newrelic.agent.introspec.TransactionEvent) Introspector(com.newrelic.agent.introspec.Introspector) ExternalRequest(com.newrelic.agent.introspec.ExternalRequest)

Example 19 with TransactionEvent

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

the class VertxFuture method testFutureFail.

@Test
public void testFutureFail() throws InterruptedException {
    failFuture();
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    assertEquals(1, introspector.getFinishedTransactionCount(500));
    String expectedTxnName = "OtherTransaction/Custom/com.nr.vertx.instrumentation.VertxFuture/failFuture";
    TransactionEvent txnEvent = introspector.getTransactionEvents(expectedTxnName).iterator().next();
    Map<String, Object> attributes = txnEvent.getAttributes();
    assertTrue(attributes.containsKey("future"));
}
Also used : TransactionEvent(com.newrelic.agent.introspec.TransactionEvent) Introspector(com.newrelic.agent.introspec.Introspector) Test(org.junit.Test)

Example 20 with TransactionEvent

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

the class VertxTestBase method getAttributesForTransaction.

Map<String, Object> getAttributesForTransaction(String expectedTxnName) {
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    assertEquals(1, introspector.getFinishedTransactionCount(TIMEOUT));
    Collection<TransactionEvent> txEvents = introspector.getTransactionEvents(expectedTxnName);
    TransactionEvent event = txEvents.iterator().next();
    return event.getAttributes();
}
Also used : TransactionEvent(com.newrelic.agent.introspec.TransactionEvent) Introspector(com.newrelic.agent.introspec.Introspector)

Aggregations

TransactionEvent (com.newrelic.agent.introspec.TransactionEvent)155 Introspector (com.newrelic.agent.introspec.Introspector)150 Test (org.junit.Test)143 ExternalRequest (com.newrelic.agent.introspec.ExternalRequest)44 URI (java.net.URI)31 TransactionTrace (com.newrelic.agent.introspec.TransactionTrace)17 TraceSegment (com.newrelic.agent.introspec.TraceSegment)14 TracedMetricData (com.newrelic.agent.introspec.TracedMetricData)10 Matchers.containsString (org.hamcrest.Matchers.containsString)9 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 Java16IncompatibleTest (com.newrelic.test.marker.Java16IncompatibleTest)6 Java17IncompatibleTest (com.newrelic.test.marker.Java17IncompatibleTest)6 Java7IncompatibleTest (com.newrelic.test.marker.Java7IncompatibleTest)6 Java9IncompatibleTest (com.newrelic.test.marker.Java9IncompatibleTest)6 CountDownLatch (java.util.concurrent.CountDownLatch)5