本文整理汇总了Java中io.vertx.ext.dropwizard.MetricsService类的典型用法代码示例。如果您正苦于以下问题:Java MetricsService类的具体用法?Java MetricsService怎么用?Java MetricsService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetricsService类属于io.vertx.ext.dropwizard包,在下文中一共展示了MetricsService类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}));
}
开发者ID:glytching,项目名称:dragoman,代码行数:24,代码来源:MetricsFacade.java
示例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);
}
}
开发者ID:codingchili,项目名称:chili-core,代码行数:18,代码来源:SystemContext.java
示例3: initHTTPConnector
import io.vertx.ext.dropwizard.MetricsService; //导入依赖的package包/类
/**
* start the server, attach the route matcher
*/
private void initHTTPConnector() {
HttpServer server = vertx.createHttpServer(new HttpServerOptions().setHost(host)
.setPort(port));
registerWebSocketHandler(server);
// TODO provide a WebSocket and a EventBus access to ServiceInfo ... this must be routed through the Router to enrich the service info with metadata from the router
routeMatcher.matchMethod(HttpMethod.GET, serviceInfoPath, request -> fetchRegitryAndUpdateMetadata((serviceInfo -> {
request.response().putHeader("content-type", "text/json");
request.response().end(serviceInfo.encodePrettily());
})));
routeMatcher.matchMethod(HttpMethod.GET,"/metrics",req -> {
MetricsService metricsService = MetricsService.create(vertx);
JsonObject metrics = metricsService.getMetricsSnapshot(vertx);
req.response().putHeader("content-type", "text/json");
req.response().end(metrics.encodePrettily());
}) ;
routeMatcher.noMatch(handler -> handler.response().end("no route found"));
server.requestHandler(routeMatcher::accept).listen(res -> {
});
}
开发者ID:amoAHCP,项目名称:vert.x-microservice,代码行数:26,代码来源:ServiceEntryPoint.java
示例4: 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);
});
}
开发者ID:sczyh30,项目名称:vertx-blueprint-microservice,代码行数:38,代码来源:MonitorDashboardVerticle.java
示例5: 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);
}
开发者ID:ANierbeck,项目名称:Karaf-Vertx,代码行数:46,代码来源:VertxService.java
示例6: ApiMetricCmd
import io.vertx.ext.dropwizard.MetricsService; //导入依赖的package包/类
ApiMetricCmd(Vertx vertx) {
this.metricsService = MetricsService.create(vertx);
}
开发者ID:edgar615,项目名称:direwolves,代码行数:4,代码来源:ApiMetricCmd.java
示例7: getServerMetrics
import io.vertx.ext.dropwizard.MetricsService; //导入依赖的package包/类
public static MetricsService getServerMetrics(){
return serverMetrics;
}
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:4,代码来源:RestVerticle.java
示例8: naming1
import io.vertx.ext.dropwizard.MetricsService; //导入依赖的package包/类
public void naming1(Vertx vertx, MetricsService metricsService) {
JsonObject metrics = metricsService.getMetricsSnapshot(vertx);
metrics.getJsonObject("vertx.eventbus.handlers");
}
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:5,代码来源:MetricsExamples.java
示例9: naming2
import io.vertx.ext.dropwizard.MetricsService; //导入依赖的package包/类
public void naming2(Vertx vertx, MetricsService metricsService) {
EventBus eventBus = vertx.eventBus();
JsonObject metrics = metricsService.getMetricsSnapshot(eventBus);
metrics.getJsonObject("handlers");
}
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:6,代码来源:MetricsExamples.java
示例10: naming3
import io.vertx.ext.dropwizard.MetricsService; //导入依赖的package包/类
public void naming3(Vertx vertx, MetricsService metricsService) {
Set<String> metricsNames = metricsService.metricsNames();
for (String metricsName : metricsNames) {
System.out.println("Known metrics name " + metricsName);
}
}
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:7,代码来源:MetricsExamples.java
示例11: 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);
}
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:6,代码来源:MetricsExamples.java
示例12: 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);
}
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:7,代码来源:MetricsExamples.java
示例13: 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");
}
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:5,代码来源:MetricsExamples.java
注:本文中的io.vertx.ext.dropwizard.MetricsService类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论