本文整理汇总了Java中io.vertx.ext.dropwizard.MetricsService.create方法的典型用法代码示例。如果您正苦于以下问题:Java MetricsService.create方法的具体用法?Java MetricsService.create怎么用?Java MetricsService.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.ext.dropwizard.MetricsService
的用法示例。
在下文中一共展示了MetricsService.create方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MetricsFacade
import io.vertx.ext.dropwizard.MetricsService; //导入方法依赖的package包/类
public MetricsFacade(Vertx vertx, HttpServer httpServer, int publicationPeriodInMillis) {
this.httpServer = httpServer;
this.metricsService = MetricsService.create(vertx);
logger.info("Scheduling metrics publication every {}ms", publicationPeriodInMillis);
// ensure that the metrics publication does *not* happen on an event loop thread
vertx.setPeriodic(
publicationPeriodInMillis,
event ->
vertx.executeBlocking(
event1 -> {
JsonObject metrics = metricsService.getMetricsSnapshot(httpServer);
if (metrics != null) {
metricsLogger.info(metrics.encode());
}
event1.complete();
},
(Handler<AsyncResult<Void>>)
event12 -> {
// no-op
}));
}
示例2: initialize
import io.vertx.ext.dropwizard.MetricsService; //导入方法依赖的package包/类
private void initialize() {
executor = vertx.createSharedWorkerExecutor("systemcontext", system().getWorkerPoolSize());
vertx.exceptionHandler(throwable -> logger.onError(throwable));
if (!initialized.get()) {
MetricsService metrics = MetricsService.create(vertx);
periodic(this::getMetricTimer, CoreStrings.LOG_METRICS, handler -> {
if (system().isMetrics()) {
JsonObject json = metrics.getMetricsSnapshot(vertx);
this.onMetricsSnapshot(json);
}
});
StartupListener.publish(this);
initialized.set(true);
}
}
示例3: start
import io.vertx.ext.dropwizard.MetricsService; //导入方法依赖的package包/类
@Override
public void start() throws Exception {
super.start();
Router router = Router.router(vertx);
// create Dropwizard metrics service
MetricsService service = MetricsService.create(vertx);
// event bus bridge
SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
BridgeOptions options = new BridgeOptions()
.addOutboundPermitted(new PermittedOptions().setAddress("microservice.monitor.metrics"))
.addOutboundPermitted(new PermittedOptions().setAddress("events.log"));
sockJSHandler.bridge(options);
router.route("/eventbus/*").handler(sockJSHandler);
// discovery endpoint
ServiceDiscoveryRestEndpoint.create(router, discovery);
// static content
router.route("/*").handler(StaticHandler.create());
int port = config().getInteger("monitor.http.port", 9100);
String host = config().getString("monitor.http.host", "0.0.0.0");
int metricsInterval = config().getInteger("monitor.metrics.interval", 5000);
vertx.createHttpServer()
.requestHandler(router::accept)
.listen(port, host);
// send metrics message to the event bus
vertx.setPeriodic(metricsInterval, t -> {
JsonObject metrics = service.getMetricsSnapshot(vertx);
vertx.eventBus().publish("microservice.monitor.metrics", metrics);
});
}
示例4: createAndRegisterVertx
import io.vertx.ext.dropwizard.MetricsService; //导入方法依赖的package包/类
private void createAndRegisterVertx() {
VertxOptions options = new VertxOptions().setMetricsOptions(new DropwizardMetricsOptions()
.setJmxEnabled(true)
.setJmxDomain("vertx-metrics")
.setRegistryName("vertx-karaf-registry")
.setFactory(metrxFactory)
);
if (cfg.getWorkerPoolSize() > 0) {
options.setWorkerPoolSize(cfg.getWorkerPoolSize());
}
if (cfg.getEventLoopPoolSize() > 0) {
options.setEventLoopPoolSize(cfg.getEventLoopPoolSize());
}
if (cfg.getHAEnabled()) {
options.setHAEnabled(cfg.getHAEnabled());
if (cfg.getHAGroup() != null && !cfg.getHAGroup().isEmpty()) {
options.setHAGroup(cfg.getHAGroup());
}
}
if (clusterManager != null) {
LOGGER.info("Starting vertx with cluster manager");
options.setClusterManager(clusterManager);
}
try {
vertx = executeWithTCCLSwitch(() -> Vertx.vertx(options));
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Error while creating vertx system", e);
return;
}
vertxRegistration = bundleContext.registerService(Vertx.class, vertx, null);
LOGGER.info("Vert.x service registered");
ebRegistration = bundleContext.registerService(EventBus.class, vertx.eventBus(), null);
LOGGER.info("Vert.x Event Bus service registered");
registry = SharedMetricRegistries.getOrCreate("vertx-karaf-registry");
metricsRegistration = bundleContext.registerService(MetricRegistry.class, registry, null);
LOGGER.info("Vert.x MetricsService service registered");
MetricsService metricsService = MetricsService.create(vertx);
metricsServiceRegistration = bundleContext.registerService(MetricsService.class, metricsService, null);
}
示例5: ApiMetricCmd
import io.vertx.ext.dropwizard.MetricsService; //导入方法依赖的package包/类
ApiMetricCmd(Vertx vertx) {
this.metricsService = MetricsService.create(vertx);
}
示例6: example1
import io.vertx.ext.dropwizard.MetricsService; //导入方法依赖的package包/类
public void example1(Vertx vertx) {
MetricsService metricsService = MetricsService.create(vertx);
JsonObject metrics = metricsService.getMetricsSnapshot(vertx);
System.out.println(metrics);
}
示例7: example2
import io.vertx.ext.dropwizard.MetricsService; //导入方法依赖的package包/类
public void example2(Vertx vertx) {
MetricsService metricsService = MetricsService.create(vertx);
HttpServer server = vertx.createHttpServer();
// set up server
JsonObject metrics = metricsService.getMetricsSnapshot(server);
}
示例8: example3
import io.vertx.ext.dropwizard.MetricsService; //导入方法依赖的package包/类
public void example3(Vertx vertx) {
MetricsService metricsService = MetricsService.create(vertx);
JsonObject metrics = metricsService.getMetricsSnapshot("vertx.eventbus.message");
}