本文整理汇总了Java中io.prometheus.client.hotspot.DefaultExports类的典型用法代码示例。如果您正苦于以下问题:Java DefaultExports类的具体用法?Java DefaultExports怎么用?Java DefaultExports使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultExports类属于io.prometheus.client.hotspot包,在下文中一共展示了DefaultExports类的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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例7: collectorRegistry
import io.prometheus.client.hotspot.DefaultExports; //导入依赖的package包/类
@Provides
@Singleton
static CollectorRegistry collectorRegistry() {
CollectorRegistry registry = CollectorRegistry.defaultRegistry;
DefaultExports.initialize();
configureLogMetrics();
return registry;
}
示例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();
}
}
示例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);
}
示例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);
}
示例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.
}
示例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);
}
}
示例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);
}
示例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);
}
示例15: PrometheusConfiguration
import io.prometheus.client.hotspot.DefaultExports; //导入依赖的package包/类
public PrometheusConfiguration() {
DefaultExports.initialize();
}