@Override public void start() { MetricsService service = MetricsService.create(vertx); JsonObject metrics = service.getMetricsSnapshot(vertx.eventBus()); if (metrics != null) { vertx.eventBus().publish("metrics", metrics);
/** * Will return the metrics that begins with the <code>baseName</code>, null if no metrics is available.<p/> * * Note: in the case of scaled servers, the JsonObject returns an aggregation of the metrics as the * dropwizard backend reports to a single server. * @param baseName * @return the map of metrics where the key is the name of the metric and the value is the json data representing that metric */ public JsonObject getMetricsSnapshot(String baseName) { JsonObject ret = delegate.getMetricsSnapshot(baseName); return ret; }
@Override public void process(CommandProcess process) { MetricsService metrics = MetricsService.create(process.vertx()); metrics.metricsNames().forEach(name -> { process.write(name + "\n"); }); process.end(); } }
/** * Creates a metric service for a given {@link io.vertx.rxjava.core.Vertx} instance. * @param vertx the vertx instance * @return the metrics service */ public static io.vertx.rxjava.ext.dropwizard.MetricsService create(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.dropwizard.MetricsService ret = io.vertx.rxjava.ext.dropwizard.MetricsService.newInstance(io.vertx.ext.dropwizard.MetricsService.create(vertx.getDelegate())); return ret; }
/** * @return the known metrics names by this service */ public Set<String> metricsNames() { Set<String> ret = delegate.metricsNames(); return ret; }
/** * @param measured the measure object * @return the base name of the measured object */ public String getBaseName(io.vertx.rxjava.core.metrics.Measured measured) { String ret = delegate.getBaseName(measured.getDelegate()); return ret; }
/** * Will return the metrics that begins with the <code>baseName</code>, null if no metrics is available.<p/> * * Note: in the case of scaled servers, the JsonObject returns an aggregation of the metrics as the * dropwizard backend reports to a single server. * @param baseName * @return the map of metrics where the key is the name of the metric and the value is the json data representing that metric */ public JsonObject getMetricsSnapshot(String baseName) { JsonObject ret = delegate.getMetricsSnapshot(baseName); return ret; }
/** * Creates a metric service for a given {@link io.vertx.rxjava.core.Vertx} instance. * @param vertx the vertx instance * @return the metrics service */ public static io.vertx.rxjava.ext.dropwizard.MetricsService create(io.vertx.rxjava.core.Vertx vertx) { io.vertx.rxjava.ext.dropwizard.MetricsService ret = io.vertx.rxjava.ext.dropwizard.MetricsService.newInstance(io.vertx.ext.dropwizard.MetricsService.create(vertx.getDelegate())); return ret; }
/** * @return the known metrics names by this service */ public Set<String> metricsNames() { Set<String> ret = delegate.metricsNames(); return ret; }
/** * @param measured the measure object * @return the base name of the measured object */ public String getBaseName(io.vertx.rxjava.core.metrics.Measured measured) { String ret = delegate.getBaseName(measured.getDelegate()); return ret; }
@Override public void process(CommandProcess process) { String name = process.args().get(0); MetricsService metrics = MetricsService.create(process.vertx()); JsonObject snapshot = metrics.getMetricsSnapshot(name); process.write(snapshot.encodePrettily() + "\n"); process.end(); } }
/** * Will return the metrics that correspond with the <code>measured</code> object, null if no metrics is available.<p/> * * Note: in the case of scaled servers, the JsonObject returns an aggregation of the metrics as the * dropwizard backend reports to a single server. * @param measured * @return the map of metrics where the key is the name of the metric (excluding the base name unless for the Vert.x object) and the value is the json data representing that metric */ public JsonObject getMetricsSnapshot(io.vertx.rxjava.core.metrics.Measured measured) { JsonObject ret = delegate.getMetricsSnapshot(measured.getDelegate()); return ret; }
public void start() { this.metricsService = MetricsService.create(vertx); HttpServer httpServer = vertx.createHttpServer(); httpServer.requestHandler(req -> { if (req.path().equals(HEALTH_PATH)) { req.response().end("ok"); } else if (req.path().equals(METRICS_PATH)) { publishMetricsSnapshot(req.response()); } else { req.response().setStatusCode(404).end("HTTP 404"); } }); // we don't start this verticle unless this was defined httpServer.listen(ipPort.getPort(), ipPort.getIp(), h -> { if (h.failed()) { log.info("failed to start admin service", h.cause()); } }); }
@Override public void process(CommandProcess process) { Vertx vertx = process.vertx(); MetricsService metrics = MetricsService.create(vertx); Map<String, Object> histogramMetrics = metrics.getMetricsSnapshot(name) .stream() .filter(e -> ((JsonObject) e.getValue()).getString("type").equals("histogram"))
/** * Will return the metrics that correspond with the <code>measured</code> object, null if no metrics is available.<p/> * * Note: in the case of scaled servers, the JsonObject returns an aggregation of the metrics as the * dropwizard backend reports to a single server. * @param measured * @return the map of metrics where the key is the name of the metric (excluding the base name unless for the Vert.x object) and the value is the json data representing that metric */ public JsonObject getMetricsSnapshot(io.vertx.rxjava.core.metrics.Measured measured) { JsonObject ret = delegate.getMetricsSnapshot(measured.getDelegate()); return ret; }
MetricsService service = MetricsService.create(vertx); JsonObject metrics = service.getMetricsSnapshot(vertx); vertx.eventBus().publish("microservice.monitor.metrics", metrics); });
public static java.util.Map<String, Object> getMetricsSnapshot(io.vertx.ext.dropwizard.MetricsService j_receiver, io.vertx.core.metrics.Measured measured) { return io.vertx.core.impl.ConversionHelper.fromJsonObject(j_receiver.getMetricsSnapshot(measured)); } public static java.util.Map<String, Object> getMetricsSnapshot(io.vertx.ext.dropwizard.MetricsService j_receiver, java.lang.String baseName) {
public static java.util.Map<String, Object> getMetricsSnapshot(io.vertx.ext.dropwizard.MetricsService j_receiver, java.lang.String baseName) { return io.vertx.core.impl.ConversionHelper.fromJsonObject(j_receiver.getMetricsSnapshot(baseName)); } }
private void publishMetricsSnapshot(HttpServerResponse rep) { rep.headers().set(HttpHeaders.CONTENT_TYPE, CONTENT_JSON); JsonObject o = new JsonObject(); o.put("http_proxy", metricsService.getMetricsSnapshot(METRICS_HTTP_PROXY_FQDN)); o.put("http_remote", metricsService.getMetricsSnapshot(METRICS_HTTP_REMOTE_FQDN)); rep.end(o.toString()); } }