use of com.newrelic.agent.introspec.HttpTestServer 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.HttpTestServer in project newrelic-java-agent by newrelic.
the class SpanParentTest method executeSpanAndTransactionParentingTest.
@Trace(dispatcher = true)
private void executeSpanAndTransactionParentingTest() throws URISyntaxException, IOException {
try (HttpTestServer server = HttpServerLocator.createAndStart()) {
nonExternalOrDatastore();
executeHttpRequest(true, server.getEndPoint().getPort());
executeFakeDatastoreRequest();
}
}
use of com.newrelic.agent.introspec.HttpTestServer in project newrelic-java-agent by newrelic.
the class SpanParentTest method executeCrossProcessOnlyTest.
@Trace(dispatcher = true)
private void executeCrossProcessOnlyTest() throws IOException, URISyntaxException {
Transaction txn = ServiceFactory.getServiceManager().getTransactionService().getTransaction(false);
DistributedTracePayloadImpl payload = DistributedTracePayloadImpl.createDistributedTracePayload(null, txn.getGuid(), txn.getGuid(), 1.0f);
txn.acceptDistributedTracePayload(payload.httpSafe());
try (HttpTestServer server = HttpServerLocator.createAndStart()) {
nonExternalOrDatastore();
executeHttpRequest(false, server.getEndPoint().getPort());
executeFakeDatastoreRequest();
}
}
Aggregations