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


Java DefaultExports.initialize方法代码示例

本文整理汇总了Java中io.prometheus.client.hotspot.DefaultExports.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultExports.initialize方法的具体用法?Java DefaultExports.initialize怎么用?Java DefaultExports.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.prometheus.client.hotspot.DefaultExports的用法示例。


在下文中一共展示了DefaultExports.initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepare

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
public static void prepare() {
    try {
        // Create server
        server = HttpServer.create(new InetSocketAddress(Config.getCatalog().webinterface.port), 0);

        // Create server for metrics
        HTTPServer metricsServer = new HTTPServer("0.0.0.0", Config.getCatalog().webinterface.metricsPort);

        metrics = new CustomMetrics();
        DefaultExports.initialize();

        // Register all handlers
        ApiRegistry.register(server);
        AuthRegistry.register(server);
        ConfirmRegistry.register(server);

        // Handle all other request static
        server.createContext("/", new NotFoundController());
    } catch (IOException e) {
        TwasiLogger.log.error(e);
        e.printStackTrace();
    }
}
 
开发者ID:Twasi,项目名称:twasi-core,代码行数:24,代码来源:WebInterfaceApp.java

示例2: main

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
public static void main( String[] args ) throws Exception {
    Server server = new Server(1234);
    ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/");
    server.setHandler(context);
    // Expose our example servlet.
    context.addServlet(new ServletHolder(new ExampleServlet()), "/");
    // Expose Promtheus metrics.
    context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics");
    // Add metrics about CPU, JVM memory etc.
    DefaultExports.initialize();


    // Start the webserver.
    server.start();
    server.join();
}
 
开发者ID:RobustPerception,项目名称:java_examples,代码行数:18,代码来源:JavaSimple.java

示例3: main

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
public static void main( String[] args ) throws Exception {
    // Increment the counter.
    counter.inc();

    // Hook the Dropwizard registry into the Prometheus registry
    // via the DropwizardExports collector.
    CollectorRegistry.defaultRegistry.register(new DropwizardExports(metrics));


    // Expose Prometheus metrics.
    Server server = new Server(1234);
    ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/");
    server.setHandler(context);
    context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics");
    // Add metrics about CPU, JVM memory etc.
    DefaultExports.initialize();
    // Start the webserver.
    server.start();
    server.join();
}
 
开发者ID:RobustPerception,项目名称:java_examples,代码行数:22,代码来源:JavaDropwizard.java

示例4: init

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
@Override
public void init(ServletConfig config) {
    DefaultExports.initialize();
    new JbossJdbcPoolExports().register();
    new UndertowExports().register();
    new InfinispanExports().register();
    new WildflyVersionExports().register();
}
 
开发者ID:nlighten,项目名称:wildfly_exporter,代码行数:9,代码来源:WildflyMetricsServlet.java

示例5: PrometheusExporter

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
public PrometheusExporter(
        MetricCollector metricCollector,
        SecureTokenManager secureTokenManager) {
    this.secureTokenManager = secureTokenManager;
    this.registry = CollectorRegistry.defaultRegistry;
    this.registry.register(metricCollector.getCollector());
    DefaultExports.initialize();
}
 
开发者ID:AndreyVMarkelov,项目名称:prom-bitbucket-exporter,代码行数:9,代码来源:PrometheusExporter.java

示例6: setup

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
public static void setup(AvaIre avaire) {
    if (isSetup) {
        throw new IllegalStateException("The metrics has already been setup!");
    }

    Metrics.avaire = avaire;

    final LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory();
    final ch.qos.logback.classic.Logger root = factory.getLogger(Logger.ROOT_LOGGER_NAME);
    final InstrumentedAppender prometheusAppender = new InstrumentedAppender();
    prometheusAppender.setContext(root.getLoggerContext());
    prometheusAppender.start();
    root.addAppender(prometheusAppender);

    // JVM (hotspot) metrics
    DefaultExports.initialize();
    Metrics.initializeEventMetrics();

    if (!avaire.getConfig().getBoolean("metrics.enabled", true)) {
        LOGGER.info("Metrics web API is disabled, skipping igniting Spark API");
        Metrics.isSetup = true;
        return;
    }

    PORT = avaire.getConfig().getInt("metrics.port", 1256);

    LOGGER.info("Igniting Spark API on port: " + PORT);

    Spark.port(PORT);

    Spark.before(new HttpFilter());
    Spark.exception(Exception.class, new SparkExceptionHandler());

    Spark.get("/metrics", new GetMetrics(MetricsHolder.METRICS));
    Spark.get("/stats", new GetStats(MetricsHolder.METRICS));

    Metrics.isSetup = true;
}
 
开发者ID:avaire,项目名称:avaire,代码行数:39,代码来源:Metrics.java

示例7: collectorRegistry

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
@Provides
@Singleton
static CollectorRegistry collectorRegistry() {
  CollectorRegistry registry = CollectorRegistry.defaultRegistry;
  DefaultExports.initialize();
  configureLogMetrics();
  return registry;
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:9,代码来源:MonitoringModule.java

示例8: init

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
@Override
public void init(ServletConfig config) {
    DefaultExports.initialize();
    new TomcatGenericExports(false).register();
    if (TomcatJdbcPoolExports.isTomcatJdbcUsed()) {
        new TomcatJdbcPoolExports().register();
    } else {
        new TomcatDbcp2PoolExports().register();
    }
}
 
开发者ID:nlighten,项目名称:tomcat_exporter,代码行数:11,代码来源:TomcatMetricsServlet.java

示例9: prometheusMetricsServletRegistrationBean

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
@Bean
@ConditionalOnMissingBean(name = "prometheusMetricsServletRegistrationBean")
ServletRegistrationBean prometheusMetricsServletRegistrationBean(@Value("${prometheus.metrics" +
        ".path:/metrics}") String metricsPath) {
    DefaultExports.initialize();
    return new ServletRegistrationBean(new MetricsServlet(), metricsPath);
}
 
开发者ID:microservices-demo,项目名称:shipping,代码行数:8,代码来源:PrometheusAutoConfiguration.java

示例10: start

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
protected static void start(String[] args, String defaultStatsPort) throws Exception {
    // Register basic JVM metrics
    DefaultExports.initialize();

    // load aspectj-weaver agent for instrumentation
    AgentLoader.loadAgentClass(Agent.class.getName(), null);

    // Start Jetty to serve stats
    int port = Integer.parseInt(System.getProperties().getProperty("stats_server_port", defaultStatsPort));

    log.info("Starting ZK stats HTTP server at port {}", port);
    InetSocketAddress httpEndpoint = InetSocketAddress.createUnresolved("0.0.0.0", port);

    Server server = new Server(httpEndpoint);
    ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/");
    server.setHandler(context);
    context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics");
    try {
        server.start();
    } catch (Exception e) {
        log.error("Failed to start HTTP server at port {}. Use \"-Dstats_server_port=1234\" to change port number",
                port, e);
        throw e;
    }

    // Start the regular ZooKeeper server
    QuorumPeerMain.main(args);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:30,代码来源:ZooKeeperStarter.java

示例11: main

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    // Add metrics about CPU, JVM memory etc.
    DefaultExports.initialize();

    Graphite g = new Graphite("localhost", 2003);
    // Send to graphite every 60s.
    Thread thread = g.start(CollectorRegistry.defaultRegistry, 60);
    thread.join();  // Waits forever.
}
 
开发者ID:RobustPerception,项目名称:java_examples,代码行数:10,代码来源:JavaGraphiteBridge.java

示例12: main

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  DefaultExports.initialize();
  HTTPServer server = new HTTPServer(8000);
  while (true) {
    myFunction();
    Thread.sleep(1000);
  }
}
 
开发者ID:RobustPerception,项目名称:java_examples,代码行数:9,代码来源:JavaExample.java

示例13: premain

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception {
  // Bind to all interfaces by default (this includes IPv6).
  String host = "0.0.0.0";

  // If we have IPv6 address in square brackets, extract it first and then
  // remove it from arguments to prevent confusion from too namy colons.
  Integer indexOfClosingSquareBracket = agentArgument.indexOf("]:");
  if (indexOfClosingSquareBracket >= 0) {
    host = agentArgument.substring(0, indexOfClosingSquareBracket + 1);
    agentArgument = agentArgument.substring(indexOfClosingSquareBracket + 2);
  }

  String[] args = agentArgument.split(":");
  if (args.length < 2 || args.length > 3) {
    System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<port>:<yaml configuration file>");
    System.exit(1);
  }

  int port;
  String file;
  InetSocketAddress socket;

  if (args.length == 3) {
    port = Integer.parseInt(args[1]);
    socket = new InetSocketAddress(args[0], port);
    file = args[2];
  } else {
    port = Integer.parseInt(args[0]);
    socket = new InetSocketAddress(host, port);
    file = args[1];
  }

  new JmxCollector(new File(file)).register();
  DefaultExports.initialize();
  server = new HTTPServer(socket, CollectorRegistry.defaultRegistry, true);
}
 
开发者ID:prometheus,项目名称:jmx_exporter,代码行数:37,代码来源:JavaAgent.java

示例14: start

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
@Override
public void start() throws Exception {
    JsonObject conf = config().getJsonObject("prometheus_exporter", new JsonObject());
    int httpPort = conf.getInteger("port", 9100);
    String path = conf.getString("path", "/metrics");

    DefaultExports.initialize();

    Router router = Router.router(vertx);
    router.route(path).handler(new MetricsHandler());
    vertx.createHttpServer().requestHandler(router::accept).listen(httpPort);
}
 
开发者ID:GruppoFilippetti,项目名称:vertx-mqtt-broker,代码行数:13,代码来源:PromMetricsExporter.java

示例15: PrometheusConfiguration

import io.prometheus.client.hotspot.DefaultExports; //导入方法依赖的package包/类
public PrometheusConfiguration() {
    DefaultExports.initialize();
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:4,代码来源:PrometheusConfiguration.java


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