当前位置: 首页>>代码示例>>Java>>正文


Java MetricsService.create方法代码示例

本文整理汇总了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
                  }));
}
 
开发者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: 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

示例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);
}
 
开发者ID:ANierbeck,项目名称:Karaf-Vertx,代码行数:46,代码来源:VertxService.java

示例5: ApiMetricCmd

import io.vertx.ext.dropwizard.MetricsService; //导入方法依赖的package包/类
ApiMetricCmd(Vertx vertx) {
  this.metricsService = MetricsService.create(vertx);
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:4,代码来源:ApiMetricCmd.java

示例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);
}
 
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:6,代码来源:MetricsExamples.java

示例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);
}
 
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:7,代码来源:MetricsExamples.java

示例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");
}
 
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:5,代码来源:MetricsExamples.java


注:本文中的io.vertx.ext.dropwizard.MetricsService.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。