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());
}
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());
}
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();
}
}
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();
}
}
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();
}
}
Aggregations