Add basic metrics + GET /metrics route
This commit is contained in:
parent
7bb1b17575
commit
a99d10c002
5
pom.xml
5
pom.xml
@ -79,6 +79,11 @@
|
||||
<artifactId>vertx-redis-client</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-dropwizard-metrics</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Google Libs -->
|
||||
<dependency>
|
||||
|
@ -37,6 +37,7 @@ import net.frozenorb.apiv3.handler.AuthorizationHandler;
|
||||
import net.frozenorb.apiv3.handler.MetricsHandler;
|
||||
import net.frozenorb.apiv3.model.*;
|
||||
import net.frozenorb.apiv3.route.GETDumpsType;
|
||||
import net.frozenorb.apiv3.route.GETMetrics;
|
||||
import net.frozenorb.apiv3.route.GETWhoAmI;
|
||||
import net.frozenorb.apiv3.route.accessTokens.DELETEAccessTokensId;
|
||||
import net.frozenorb.apiv3.route.accessTokens.GETAccessTokens;
|
||||
@ -358,6 +359,7 @@ public final class APIv3 extends AbstractVerticle {
|
||||
http.post("/users/:userId/verifyTotp").handler(new POSTUsersIdVerifyTotp());
|
||||
|
||||
http.get("/dumps/:dumpType").handler(new GETDumpsType());
|
||||
http.get("/metrics").handler(new GETMetrics());
|
||||
http.get("/whoami").handler(new GETWhoAmI());
|
||||
|
||||
int port = Integer.parseInt(config.getProperty("http.port"));
|
||||
|
@ -1,6 +1,8 @@
|
||||
package net.frozenorb.apiv3;
|
||||
|
||||
import io.vertx.core.Vertx;
|
||||
import io.vertx.core.VertxOptions;
|
||||
import io.vertx.ext.dropwizard.DropwizardMetricsOptions;
|
||||
|
||||
final class Main {
|
||||
|
||||
@ -8,7 +10,7 @@ final class Main {
|
||||
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "error");
|
||||
System.setProperty("org.slf4j.simpleLogger.showThreadName", "false");
|
||||
System.setProperty("vertx.logger-delegate-factory-class-name", "io.vertx.core.logging.SLF4JLogDelegateFactory");
|
||||
Vertx.vertx().deployVerticle(new APIv3());
|
||||
Vertx.vertx(new VertxOptions().setMetricsOptions(new DropwizardMetricsOptions().setEnabled(true))).deployVerticle(new APIv3());
|
||||
}
|
||||
|
||||
}
|
18
src/main/java/net/frozenorb/apiv3/route/GETMetrics.java
Normal file
18
src/main/java/net/frozenorb/apiv3/route/GETMetrics.java
Normal file
@ -0,0 +1,18 @@
|
||||
package net.frozenorb.apiv3.route;
|
||||
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.dropwizard.MetricsService;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
|
||||
public final class GETMetrics implements Handler<RoutingContext> {
|
||||
|
||||
public void handle(RoutingContext ctx) {
|
||||
MetricsService metricsService = MetricsService.create(APIv3.getVertxInstance());
|
||||
JsonObject metrics = metricsService.getMetricsSnapshot(APIv3.getVertxInstance());
|
||||
|
||||
APIv3.respondJson(ctx, 200, metrics);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user