Search in sources :

Example 1 with ProductHandlers

use of com.nr.vertx.test.handlers.ProductHandlers in project newrelic-java-agent by newrelic.

the class HandlerTracingTest method testLambdaNames.

@Test
public void testLambdaNames() {
    Vertx vertx = Vertx.vertx();
    try {
        Router router = Router.router(vertx);
        router.route().path("/products").handler(ProductHandlers::getAllProducts);
        router.route().path("/product/:pid").handler(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)

Example 2 with ProductHandlers

use of com.nr.vertx.test.handlers.ProductHandlers 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)2 ProductHandlers (com.nr.vertx.test.handlers.ProductHandlers)2 Vertx (io.vertx.core.Vertx)2 HttpServer (io.vertx.core.http.HttpServer)2 Router (io.vertx.ext.web.Router)2 Test (org.junit.Test)2