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();
}
}
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());
}
}
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"));
}
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"));
}
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();
}
Aggregations