use of com.newrelic.agent.introspec.ExternalRequest in project newrelic-java-agent by newrelic.
the class HttpServerTest method testExternalCall.
@Test
public void testExternalCall() throws IOException, URISyntaxException {
Introspector intro = InstrumentationTestRunner.getIntrospector();
HttpRequestClass myClass = new HttpRequestClass();
myClass.performHttp(server.getEndPoint());
assertEquals(2, intro.getFinishedTransactionCount());
Collection<String> names = intro.getTransactionNames();
assertEquals(2, names.size());
String txName1 = "OtherTransaction/Custom/com.example.http.HttpRequestClass/performHttp";
String txName2 = "WebTransaction/Custom/ExternalHTTPServer";
assertTrue(names.contains(txName1));
assertTrue(names.contains(txName2));
Collection<ExternalRequest> externals = intro.getExternalRequests(txName1);
assertEquals(1, externals.size());
ExternalRequest req = externals.iterator().next();
assertEquals(1, req.getCount());
assertEquals("localhost", req.getHostname());
assertEquals("NewRelicApacheHttp", req.getLibrary());
}
use of com.newrelic.agent.introspec.ExternalRequest in project newrelic-java-agent by newrelic.
the class HttpClient4Test method testCat.
@Test
public void testCat() throws Exception {
Introspector introspector = InstrumentationTestRunner.getIntrospector();
URI endpoint = server.getEndPoint();
String host = endpoint.getHost();
httpClientExternal(endpoint.toURL().toString(), true);
// transaction
String txName = "OtherTransaction/Custom/com.nr.agent.instrumentation.httpclient.HttpClient4Test/httpClientExternal";
assertEquals(2, introspector.getFinishedTransactionCount());
Collection<String> names = introspector.getTransactionNames();
assertEquals(2, names.size());
assertTrue(names.contains(server.getServerTransactionName()));
assertTrue(names.contains(txName));
// scoped metrics
assertEquals(1, MetricsHelper.getScopedMetricCount(txName, "ExternalTransaction/" + host + "/" + server.getCrossProcessId() + "/" + server.getServerTransactionName()));
assertEquals(1, MetricsHelper.getScopedMetricCount(txName, "Java/com.nr.agent.instrumentation.httpclient.HttpClient4Test/httpClientExternal"));
// unscoped metrics
assertEquals(1, MetricsHelper.getUnscopedMetricCount("ExternalTransaction/" + host + "/" + server.getCrossProcessId() + "/" + server.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.ExternalRequest in project newrelic-java-agent by newrelic.
the class HttpClient3Test method testCat.
@Test
public void testCat() throws Exception {
URI endpoint = server.getEndPoint();
String host = endpoint.getHost();
int status = httpClientExternal(endpoint.toURL().toString(), true);
assertEquals(200, status);
Introspector introspector = InstrumentationTestRunner.getIntrospector();
assertEquals(2, introspector.getFinishedTransactionCount());
String txName = "OtherTransaction/Custom/com.nr.agent.instrumentation.httpclient.HttpClient3Test/httpClientExternal";
Collection<String> names = introspector.getTransactionNames();
assertEquals(2, names.size());
assertTrue(names.contains(server.getServerTransactionName()));
assertTrue(names.contains(txName));
// scoped metrics
assertEquals(1, MetricsHelper.getScopedMetricCount(txName, "ExternalTransaction/" + host + "/" + server.getCrossProcessId() + "/" + server.getServerTransactionName()));
assertEquals(1, MetricsHelper.getScopedMetricCount(txName, "Java/com.nr.agent.instrumentation.httpclient.HttpClient3Test/httpClientExternal"));
// unscoped metrics
assertEquals(1, MetricsHelper.getUnscopedMetricCount("ExternalTransaction/" + host + "/" + server.getCrossProcessId() + "/" + server.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());
assertEquals(Integer.valueOf(200), externalRequest.getStatusCode());
assertEquals("OK", externalRequest.getStatusText());
}
use of com.newrelic.agent.introspec.ExternalRequest in project newrelic-java-agent by newrelic.
the class HttpClient3Test method testExternal.
@Test
public void testExternal() throws Exception {
httpClientExternal("http://localhost:" + server.getEndPoint().getPort());
Introspector introspector = InstrumentationTestRunner.getIntrospector();
Assert.assertEquals(2, introspector.getFinishedTransactionCount());
String txOne = "OtherTransaction/Custom/com.nr.agent.instrumentation.httpclient.HttpClient3Test/httpClientExternal";
Assert.assertEquals(1, MetricsHelper.getScopedMetricCount(txOne, "External/localhost/CommonsHttp/execute"));
Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/localhost/CommonsHttp/execute"));
// external rollups
Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/localhost/all"));
Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/allOther"));
Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/all"));
Collection<TransactionEvent> transactionEvents = introspector.getTransactionEvents(txOne);
Assert.assertEquals(1, transactionEvents.size());
TransactionEvent transactionEvent = transactionEvents.iterator().next();
Assert.assertEquals(1, transactionEvent.getExternalCallCount());
Assert.assertTrue(transactionEvent.getExternalDurationInSec() > 0);
Collection<ExternalRequest> externalRequests = introspector.getExternalRequests(txOne);
Assert.assertEquals(1, externalRequests.size());
ExternalRequest externalRequest = externalRequests.iterator().next();
Assert.assertEquals(1, externalRequest.getCount());
Assert.assertEquals("localhost", externalRequest.getHostname());
Assert.assertEquals("CommonsHttp", externalRequest.getLibrary());
Assert.assertEquals("execute", externalRequest.getOperation());
Assert.assertEquals(Integer.valueOf(200), externalRequest.getStatusCode());
Assert.assertEquals("OK", externalRequest.getStatusText());
}
use of com.newrelic.agent.introspec.ExternalRequest in project newrelic-java-agent by newrelic.
the class HttpAsyncClient4Test method testExternal.
@Test
public void testExternal() throws IOException, InterruptedException, ExecutionException {
httpClientExternal(endpoint.toString(), false);
Introspector introspector = InstrumentationTestRunner.getIntrospector();
Assert.assertEquals(2, introspector.getFinishedTransactionCount());
String txOne = null;
for (String txName : introspector.getTransactionNames()) {
if (txName.matches(".*HttpAsyncClient.*")) {
txOne = txName;
}
}
Assert.assertNotNull("Transaction not found", txOne);
Assert.assertEquals(1, MetricsHelper.getScopedMetricCount(txOne, "External/" + host + "/HttpAsyncClient/responseCompleted"));
Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/" + host + "/HttpAsyncClient/responseCompleted"));
// external rollups
Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/" + host + "/all"));
Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/allOther"));
Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/all"));
Collection<TransactionEvent> transactionEvents = introspector.getTransactionEvents(txOne);
Assert.assertEquals(1, transactionEvents.size());
TransactionEvent transactionEvent = transactionEvents.iterator().next();
Assert.assertEquals(1, transactionEvent.getExternalCallCount());
Assert.assertTrue(transactionEvent.getExternalDurationInSec() > 0);
Collection<ExternalRequest> externalRequests = introspector.getExternalRequests(txOne);
Assert.assertEquals(1, externalRequests.size());
ExternalRequest externalRequest = externalRequests.iterator().next();
Assert.assertEquals(1, externalRequest.getCount());
Assert.assertEquals(host, externalRequest.getHostname());
Assert.assertEquals("HttpAsyncClient", externalRequest.getLibrary());
Assert.assertEquals("responseCompleted", externalRequest.getOperation());
Assert.assertEquals(Integer.valueOf(200), externalRequest.getStatusCode());
Assert.assertEquals("OK", externalRequest.getStatusText());
}
Aggregations