use of com.newrelic.agent.introspec.ExternalRequest in project newrelic-java-agent by newrelic.
the class OkHttp4Test method testCat.
@Test
public void testCat() throws Exception {
Introspector introspector = InstrumentationTestRunner.getIntrospector();
URI endpoint = server.getEndPoint();
httpClientExternal(endpoint.toURL().toString());
// transaction
assertEquals(2, introspector.getFinishedTransactionCount());
Collection<String> names = introspector.getTransactionNames();
assertEquals(2, names.size());
assertTrue(names.contains(server.getServerTransactionName()));
String txName = "OtherTransaction/Custom/com.nr.agent.instrumentation.okhttp4.OkHttp4Test/httpClientExternal";
assertTrue(names.contains(txName));
// scoped metrics
String host = endpoint.getHost();
assertEquals(1, MetricsHelper.getScopedMetricCount(txName, "ExternalTransaction/" + host + "/" + server.getCrossProcessId() + "/" + server.getServerTransactionName()));
assertEquals(1, MetricsHelper.getScopedMetricCount(txName, "Java/com.nr.agent.instrumentation.okhttp4.OkHttp4Test/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());
Assert.assertEquals(Integer.valueOf(200), externalRequest.getStatusCode());
// the test server does return the trailing space, this client does not trim it
Assert.assertEquals("OK ", externalRequest.getStatusText());
}
use of com.newrelic.agent.introspec.ExternalRequest in project newrelic-java-agent by newrelic.
the class OkHttp35Test method testCat.
@Test
public void testCat() throws Exception {
Introspector introspector = InstrumentationTestRunner.getIntrospector();
URI endpoint = server.getEndPoint();
String host = endpoint.getHost();
httpClientExternal(endpoint.toURL().toString());
// transaction
String txName = "OtherTransaction/Custom/com.nr.agent.instrumentation.okhttp35.OkHttp35Test/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.okhttp35.OkHttp35Test/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());
Assert.assertEquals(Integer.valueOf(200), externalRequest.getStatusCode());
// the test server does return the trailing space, this client does not trim it
Assert.assertEquals("OK ", externalRequest.getStatusText());
}
use of com.newrelic.agent.introspec.ExternalRequest in project newrelic-java-agent by newrelic.
the class OkHttp36Test method testExternal.
@Test
public void testExternal() throws Exception {
URI endpoint = server.getEndPoint();
String host1 = endpoint.getHost();
httpClientExternal(endpoint.toString(), false, 2000);
Introspector introspector = InstrumentationTestRunner.getIntrospector();
Assert.assertEquals(2, introspector.getFinishedTransactionCount());
String txOne = null;
for (String txName : introspector.getTransactionNames()) {
if (txName.matches(".*OkHttp36Test.*")) {
txOne = txName;
}
}
Assert.assertNotNull("Transaction not found", txOne);
Assert.assertEquals(1, MetricsHelper.getScopedMetricCount(txOne, "External/" + host1 + "/OkHttp/execute"));
Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/" + host1 + "/OkHttp/execute"));
// external rollups
Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/" + host1 + "/all"));
Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/allOther"));
Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/all"));
// verify timing of External/all metrics
TracedMetricData externalMetrics = InstrumentationTestRunner.getIntrospector().getUnscopedMetrics().get("External/all");
assertNotNull(externalMetrics);
assertTrue(externalMetrics.getTotalTimeInSec() > 2);
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(host1, externalRequest.getHostname());
Assert.assertEquals("OkHttp", externalRequest.getLibrary());
Assert.assertEquals("execute", externalRequest.getOperation());
Assert.assertEquals(Integer.valueOf(200), externalRequest.getStatusCode());
// the test server does return the trailing space, this client does not trim it
Assert.assertEquals("OK ", externalRequest.getStatusText());
}
use of com.newrelic.agent.introspec.ExternalRequest in project newrelic-java-agent by newrelic.
the class WebClientTest method validateOutcomes.
private void validateOutcomes(String txnName) {
final Introspector introspector = InstrumentationTestRunner.getIntrospector();
assertEquals(1, introspector.getFinishedTransactionCount(TIMEOUT));
assertTrue(introspector.getTransactionNames().contains(txnName));
Collection<ExternalRequest> externalRequests = introspector.getExternalRequests(txnName);
Assert.assertEquals(1, externalRequests.size());
ExternalRequest externalRequest = externalRequests.iterator().next();
Assert.assertEquals("Spring-WebClient", externalRequest.getLibrary());
Assert.assertEquals("exchange", externalRequest.getOperation());
Assert.assertEquals(1, MetricsHelper.getScopedMetricCount(txnName, "External/" + host + "/Spring-WebClient/exchange"));
Assert.assertEquals(1, MetricsHelper.getUnscopedMetricCount("External/" + host + "/Spring-WebClient/exchange"));
// 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(txnName);
Assert.assertEquals(1, transactionEvents.size());
TransactionEvent transactionEvent = transactionEvents.iterator().next();
Assert.assertEquals(1, transactionEvent.getExternalCallCount());
Assert.assertTrue(transactionEvent.getExternalDurationInSec() > 0);
}
use of com.newrelic.agent.introspec.ExternalRequest in project newrelic-java-agent by newrelic.
the class WebClientTest method testCat.
@Test
public void testCat() {
Introspector introspector = InstrumentationTestRunner.getIntrospector();
final String response = makeCatRequest(catEndpoint).block().bodyToMono(String.class).block();
assertEquals("<html><body><h1>SuccessfulResponse</h1>\n</body></html>\n", response);
// transaction
String txName = "OtherTransaction/Custom/com.nr.instrumentation.WebClientTest/makeCatRequest";
assertEquals(2, introspector.getFinishedTransactionCount(// One transaction is the one we care about and the other is the server-side CAT tx
TIMEOUT));
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.instrumentation.WebClientTest/makeCatRequest"));
// 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());
}
Aggregations