Search in sources :

Example 61 with TracedMetricData

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

the class SpringControllerTests method testNestedPathAnnotation.

@Test
public void testNestedPathAnnotation() {
    assertEquals("nestedPathAnnotation", App.nestedPathAnnotation());
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    String expectedTransactionName = "OtherTransaction/SpringController/nestedPath/innerPath (GET)";
    Map<String, TracedMetricData> metrics = introspector.getMetricsForTransaction(expectedTransactionName);
    assertEquals(1, metrics.get("Java/com.nr.agent.instrumentation.NestedPathAnnotationTest/nestedPath").getCallCount());
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Introspector(com.newrelic.agent.introspec.Introspector) Test(org.junit.Test)

Example 62 with TracedMetricData

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

the class SpringControllerTests method testErrorPath.

@Test
public void testErrorPath() {
    App.error();
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    String expectedTransactionName = "OtherTransaction/SpringController/errorPath (GET)";
    Map<String, TracedMetricData> metrics = introspector.getMetricsForTransaction(expectedTransactionName);
    assertEquals(1, metrics.get("Java/com.nr.agent.instrumentation.ErrorPath/testError").getCallCount());
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Introspector(com.newrelic.agent.introspec.Introspector) Test(org.junit.Test)

Example 63 with TracedMetricData

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

the class ExpireAndEndHandlerTest method testResponseOtherThread.

@Test
public void testResponseOtherThread() {
    Vertx vertx = Vertx.vertx();
    try {
        Router router = Router.router(vertx);
        router.route().path("/really-async").handler(ctx -> {
            new Thread(() -> {
                ctx.response().putHeader("content-type", "text/plain").end("Response written from separate thread");
            }).start();
        });
        HttpServer server = createServer(vertx, router);
        getRequest("/really-async", server).then().statusCode(200);
        Introspector introspector = InstrumentationTestRunner.getIntrospector();
        assertEquals(1, introspector.getFinishedTransactionCount(500));
        Map<String, TracedMetricData> metrics = getMetrics("OtherTransaction/Vertx/really-async (GET)");
        assertTrue(metrics.containsKey("com.nr.vertx.instrumentation.ExpireAndEndHandlerTest.lambda()"));
    } finally {
        vertx.close();
    }
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) HttpServer(io.vertx.core.http.HttpServer) Router(io.vertx.ext.web.Router) Introspector(com.newrelic.agent.introspec.Introspector) Vertx(io.vertx.core.Vertx) Test(org.junit.Test)

Example 64 with TracedMetricData

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

the class ExpireAndEndHandlerTest method testJDBC.

@Test
public void testJDBC() {
    Vertx vertx = Vertx.vertx();
    try {
        Router router = Router.router(vertx);
        JDBCClient client = JDBCClient.createShared(vertx, new JsonObject().put("url", "jdbc:hsqldb:mem:test?shutdown=true").put("driver_class", "org.hsqldb.jdbcDriver"));
        router.route().path("/jdbc").handler(ctx -> client.getConnection(res -> {
            if (res.failed()) {
                ctx.response().setStatusCode(504).end();
            } else {
                SQLConnection conn = res.result();
                conn.queryWithParams("SELECT id, name, price, weight FROM products where id = ?", new JsonArray().add(8), query -> {
                    ctx.response().setStatusCode(500).end();
                });
            }
        }));
        HttpServer server = createServer(vertx, router);
        getRequest("/jdbc", server).then().statusCode(500);
        Introspector introspector = InstrumentationTestRunner.getIntrospector();
        assertEquals(1, introspector.getFinishedTransactionCount(500));
        Map<String, TracedMetricData> metrics = getMetrics("OtherTransaction/Vertx/jdbc (GET)");
        assertTrue(metrics.containsKey("com.nr.vertx.instrumentation.ExpireAndEndHandlerTest.lambda()"));
    } finally {
        vertx.close();
    }
}
Also used : HttpServer(io.vertx.core.http.HttpServer) Vertx(io.vertx.core.Vertx) RunWith(org.junit.runner.RunWith) Introspector(com.newrelic.agent.introspec.Introspector) Router(io.vertx.ext.web.Router) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) JsonArray(io.vertx.core.json.JsonArray) JDBCClient(io.vertx.ext.jdbc.JDBCClient) Map(java.util.Map) SQLConnection(io.vertx.ext.sql.SQLConnection) JsonObject(io.vertx.core.json.JsonObject) InstrumentationTestConfig(com.newrelic.agent.introspec.InstrumentationTestConfig) TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) Assert.assertEquals(org.junit.Assert.assertEquals) InstrumentationTestRunner(com.newrelic.agent.introspec.InstrumentationTestRunner) JsonArray(io.vertx.core.json.JsonArray) TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) SQLConnection(io.vertx.ext.sql.SQLConnection) HttpServer(io.vertx.core.http.HttpServer) Router(io.vertx.ext.web.Router) JDBCClient(io.vertx.ext.jdbc.JDBCClient) JsonObject(io.vertx.core.json.JsonObject) Introspector(com.newrelic.agent.introspec.Introspector) Vertx(io.vertx.core.Vertx) Test(org.junit.Test)

Example 65 with TracedMetricData

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

the class HandlerTracingTest method testLambdaNamesBlocking.

@Test
public void testLambdaNamesBlocking() {
    Vertx vertx = Vertx.vertx();
    try {
        Router router = Router.router(vertx);
        router.route().path("/products").blockingHandler(ProductHandlers::getAllProducts);
        router.route().path("/product/:pid").blockingHandler(ProductHandlers.getProductHandler());
        HttpServer server = createServer(vertx, router);
        getRequest("/products/", server).then().statusCode(200);
        Map<String, TracedMetricData> metrics = getMetrics("OtherTransaction/Vertx/products (GET)");
        assertTrue(metrics.containsKey("com.nr.vertx.instrumentation.HandlerTracingTest.lambda()"));
        InstrumentationTestRunner.getIntrospector().clear();
        getRequest("/product/milk", server).then().statusCode(200);
        metrics = getMetrics("OtherTransaction/Vertx/product/:pid (GET)");
        assertTrue(metrics.containsKey("com.nr.vertx.test.handlers.ProductHandlers.lambda()"));
        InstrumentationTestRunner.getIntrospector().clear();
    } finally {
        vertx.close();
    }
}
Also used : TracedMetricData(com.newrelic.agent.introspec.TracedMetricData) HttpServer(io.vertx.core.http.HttpServer) Router(io.vertx.ext.web.Router) ProductHandlers(com.nr.vertx.test.handlers.ProductHandlers) Vertx(io.vertx.core.Vertx) Test(org.junit.Test)

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