use of com.newrelic.agent.introspec.ExternalRequest in project newrelic-java-agent by newrelic.
the class HttpClient31Test 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.HttpClient31Test/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.HttpClient31Test/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 VertxClient method testMethods.
@Test
public void testMethods() throws InterruptedException {
requestMethods();
assertEquals(1, InstrumentationTestRunner.getIntrospector().getFinishedTransactionCount(1000));
final ExternalRequest externalRequest = InstrumentationTestRunner.getIntrospector().getExternalRequests("OtherTransaction/Custom/com.nr.vertx.instrumentation.VertxClient/requestMethods").iterator().next();
assertEquals(5, externalRequest.getCount());
assertEquals(5, MetricsHelper.getUnscopedMetricCount("External/localhost/all"));
assertEquals(5, MetricsHelper.getUnscopedMetricCount("External/allOther"));
assertEquals(5, MetricsHelper.getUnscopedMetricCount("External/all"));
}
use of com.newrelic.agent.introspec.ExternalRequest in project newrelic-java-agent by newrelic.
the class VertxClient method testEndMethods.
@Test
public void testEndMethods() throws InterruptedException {
endMethods();
assertEquals(1, InstrumentationTestRunner.getIntrospector().getFinishedTransactionCount(1000));
final ExternalRequest externalRequest = InstrumentationTestRunner.getIntrospector().getExternalRequests("OtherTransaction/Custom/com.nr.vertx.instrumentation.VertxClient/endMethods").iterator().next();
assertEquals(4, externalRequest.getCount());
assertEquals(4, MetricsHelper.getUnscopedMetricCount("External/localhost/all"));
assertEquals(4, MetricsHelper.getUnscopedMetricCount("External/allOther"));
assertEquals(4, MetricsHelper.getUnscopedMetricCount("External/all"));
}
use of com.newrelic.agent.introspec.ExternalRequest in project newrelic-java-agent by newrelic.
the class Jersey2ClientTest method testCat.
@Test
public void testCat() throws Exception {
Introspector introspector = InstrumentationTestRunner.getIntrospector();
URI endpoint = server.getEndPoint();
String host = endpoint.getHost();
makeExternalRequest(endpoint.toURL().toString(), true);
// transaction
String txName = "OtherTransaction/Custom/com.nr.agent.instrumentation.jerseyclient2.Jersey2ClientTest/makeExternalRequest";
assertEquals(2, introspector.getFinishedTransactionCount(3000));
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.jerseyclient2.Jersey2ClientTest/makeExternalRequest"));
// 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 Jersey2ClientTest method testAsync.
@Test
public void testAsync() throws Exception {
Introspector introspector = InstrumentationTestRunner.getIntrospector();
URI endpoint = server.getEndPoint();
requestHttpMethodsAsync(endpoint.toString());
// transaction
String txName = "OtherTransaction/Custom/com.nr.agent.instrumentation.jerseyclient2.Jersey2ClientTest/requestHttpMethodsAsync";
assertEquals(1, introspector.getFinishedTransactionCount(2000));
Collection<String> names = introspector.getTransactionNames();
assertTrue(names.contains(txName));
// external request test should go here
Collection<ExternalRequest> externalRequests = introspector.getExternalRequests(txName);
assertEquals(4, externalRequests.size());
assertEquals(4, MetricsHelper.getUnscopedMetricCount("External/localhost/all"));
assertEquals(4, MetricsHelper.getUnscopedMetricCount("External/allOther"));
assertEquals(4, MetricsHelper.getUnscopedMetricCount("External/all"));
}
Aggregations