Search in sources :

Example 36 with TracedMetricData

use of com.newrelic.agent.introspec.TracedMetricData in project newrelic-java-agent by newrelic.

the class HttpClient3Test method httpClient5.

@Test
public void httpClient5() throws IOException, URISyntaxException {
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    URI endpoint = server.getEndPoint();
    execute5(endpoint);
    Map<String, TracedMetricData> metrics = introspector.getMetricsForTransaction("OtherTransaction/Custom/com.nr.agent.instrumentation.httpclient.HttpClient3Test/execute5");
    Assert.assertTrue(metrics.containsKey("External/" + endpoint.getHost() + "/CommonsHttp"));
    metrics.get("External/" + endpoint.getHost() + "/CommonsHttp");
    // execute5() calls execute() and releaseConnection(), both are instrumented
    Assert.assertEquals(1, metrics.get("External/" + endpoint.getHost() + "/CommonsHttp/execute").getCallCount());
    Assert.assertEquals(1, metrics.get("External/" + endpoint.getHost() + "/CommonsHttp").getCallCount());
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Introspector(com.newrelic.agent.introspec.Introspector) URI(java.net.URI) Test(org.junit.Test)

Example 37 with TracedMetricData

use of com.newrelic.agent.introspec.TracedMetricData in project newrelic-java-agent by newrelic.

the class HttpClient3Test method httpClient4.

@Test
public void httpClient4() throws IOException, URISyntaxException, InterruptedException {
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    URI endpoint = server.getEndPoint();
    execute4(endpoint);
    Map<String, TracedMetricData> metrics = introspector.getMetricsForTransaction("OtherTransaction/Custom/com.nr.agent.instrumentation.httpclient.HttpClient3Test/execute4");
    Assert.assertTrue(metrics.containsKey("External/" + endpoint.getHost() + "/CommonsHttp"));
    metrics.get("External/" + endpoint.getHost() + "/CommonsHttp");
    // execute4() calls execute(), getResponseBody() and releaseConnection(). All 3 methods are instrumented
    // execute() has a metric of its own, the others are aggregated in the general metric
    Assert.assertEquals(1, metrics.get("External/" + endpoint.getHost() + "/CommonsHttp/execute").getCallCount());
    Assert.assertEquals(2, metrics.get("External/" + endpoint.getHost() + "/CommonsHttp").getCallCount());
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Introspector(com.newrelic.agent.introspec.Introspector) URI(java.net.URI) Test(org.junit.Test)

Example 38 with TracedMetricData

use of com.newrelic.agent.introspec.TracedMetricData in project newrelic-java-agent by newrelic.

the class HttpClient3Test method httpClient2.

@Test
public void httpClient2() throws IOException, URISyntaxException {
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    URI endpoint = server.getEndPoint();
    execute2(endpoint);
    Map<String, TracedMetricData> metrics = introspector.getMetricsForTransaction("OtherTransaction/Custom/com.nr.agent.instrumentation.httpclient.HttpClient3Test/execute2");
    Assert.assertTrue(metrics.containsKey("External/" + endpoint.getHost() + "/CommonsHttp"));
    metrics.get("External/" + endpoint.getHost() + "/CommonsHttp");
    // execute2() calls execute() and releaseConnection(), both are instrumented
    Assert.assertEquals(1, metrics.get("External/" + endpoint.getHost() + "/CommonsHttp/execute").getCallCount());
    Assert.assertEquals(1, metrics.get("External/" + endpoint.getHost() + "/CommonsHttp").getCallCount());
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Introspector(com.newrelic.agent.introspec.Introspector) URI(java.net.URI) Test(org.junit.Test)

Example 39 with TracedMetricData

use of com.newrelic.agent.introspec.TracedMetricData in project newrelic-java-agent by newrelic.

the class HttpClient3Test method httpClient3.

@Test
public void httpClient3() throws IOException, URISyntaxException {
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    URI endpoint = server.getEndPoint();
    execute3(endpoint);
    Map<String, TracedMetricData> metrics = introspector.getMetricsForTransaction("OtherTransaction/Custom/com.nr.agent.instrumentation.httpclient.HttpClient3Test/execute3");
    Assert.assertTrue(metrics.containsKey("External/" + endpoint.getHost() + "/CommonsHttp"));
    metrics.get("External/" + endpoint.getHost() + "/CommonsHttp");
    // execute3() calls execute() and releaseConnection(), both are instrumented
    Assert.assertEquals(1, metrics.get("External/" + endpoint.getHost() + "/CommonsHttp/execute").getCallCount());
    Assert.assertEquals(1, metrics.get("External/" + endpoint.getHost() + "/CommonsHttp").getCallCount());
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Introspector(com.newrelic.agent.introspec.Introspector) URI(java.net.URI) Test(org.junit.Test)

Example 40 with TracedMetricData

use of com.newrelic.agent.introspec.TracedMetricData in project newrelic-java-agent by newrelic.

the class SqsAsyncClientTest method checkScopedMetricCount.

public static void checkScopedMetricCount(String transactionName, String metricName, int expected) {
    TracedMetricData data = InstrumentationTestRunner.getIntrospector().getMetricsForTransaction(transactionName).get(metricName);
    Assert.assertEquals(expected, data.getCallCount());
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData)

Aggregations

TracedMetricData (com.newrelic.agent.introspec.TracedMetricData)65 Test (org.junit.Test)58 Introspector (com.newrelic.agent.introspec.Introspector)51 Java7IncompatibleTest (com.newrelic.test.marker.Java7IncompatibleTest)15 URI (java.net.URI)12 TransactionEvent (com.newrelic.agent.introspec.TransactionEvent)10 ExternalRequest (com.newrelic.agent.introspec.ExternalRequest)7 Tracer (com.newrelic.agent.tracers.Tracer)7 TransactionTrace (com.newrelic.agent.introspec.TransactionTrace)6 AMQP (com.rabbitmq.client.AMQP)6 DefaultConsumer (com.rabbitmq.client.DefaultConsumer)6 Envelope (com.rabbitmq.client.Envelope)6 IOException (java.io.IOException)6 ActorSystem (akka.actor.ActorSystem)5 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)4 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)4 Vertx (io.vertx.core.Vertx)4 HttpServer (io.vertx.core.http.HttpServer)4 TraceSegment (com.newrelic.agent.introspec.TraceSegment)3 Trace (com.newrelic.api.agent.Trace)3