Search in sources :

Example 1 with HttpTestServer

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());
    }
}
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 2 with HttpTestServer

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();
    }
}
Also used : HttpTestServer(com.newrelic.agent.introspec.HttpTestServer)

Example 3 with HttpTestServer

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();
    }
}
Also used : Transaction(com.newrelic.agent.Transaction) HttpTestServer(com.newrelic.agent.introspec.HttpTestServer) DistributedTracePayloadImpl(com.newrelic.agent.tracing.DistributedTracePayloadImpl)

Aggregations

HttpTestServer (com.newrelic.agent.introspec.HttpTestServer)3 Transaction (com.newrelic.agent.Transaction)1 ExternalRequest (com.newrelic.agent.introspec.ExternalRequest)1 Introspector (com.newrelic.agent.introspec.Introspector)1 TransactionEvent (com.newrelic.agent.introspec.TransactionEvent)1 DistributedTracePayloadImpl (com.newrelic.agent.tracing.DistributedTracePayloadImpl)1 Test (org.junit.Test)1