use of io.prometheus.client.dropwizard.DropwizardExports in project vertx-examples by vert-x3.
the class PrometheusMetricsVerticle method start.
@Override
public void start() throws Exception {
MetricRegistry metricRegistry = SharedMetricRegistries.getOrCreate("exported");
CollectorRegistry.defaultRegistry.register(new DropwizardExports(metricRegistry));
// Bind metrics handler to /metrics
Router router = Router.router(vertx);
router.get("/metrics").handler(new MetricsHandler());
// Start httpserver on localhost:8080
vertx.createHttpServer().requestHandler(router::accept).listen(8080);
// Increase counter every second
vertx.setPeriodic(1_000L, e -> metricRegistry.counter("testCounter").inc());
}
use of io.prometheus.client.dropwizard.DropwizardExports in project dcos-commons by mesosphere.
the class Metrics method configureMetricsEndpoints.
/**
* Appends endpoint servlets to the provided {@code context} which will serve codahale-style and prometheus-style
* metrics.
*/
public static void configureMetricsEndpoints(ServletContextHandler context, String codahaleMetricsEndpoint, String prometheusEndpoint) {
// Metrics
ServletHolder codahaleMetricsServlet = new ServletHolder("default", new com.codahale.metrics.servlets.MetricsServlet(metrics));
context.addServlet(codahaleMetricsServlet, codahaleMetricsEndpoint);
// Prometheus
CollectorRegistry collectorRegistry = new CollectorRegistry();
collectorRegistry.register(new DropwizardExports(metrics));
ServletHolder prometheusServlet = new ServletHolder("prometheus", new io.prometheus.client.exporter.MetricsServlet(collectorRegistry));
context.addServlet(prometheusServlet, prometheusEndpoint);
}
use of io.prometheus.client.dropwizard.DropwizardExports in project copper-cms by PogeyanOSS.
the class AkkaServletContextListener method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent sce) {
ActorSystem system = ActorSystem.create("GatewaySystem");
sce.getServletContext().setAttribute("ActorSystem", system);
String configFilename = sce.getServletContext().getInitParameter(CONFIG_INIT_PARAM);
if (configFilename == null) {
configFilename = CONFIG_FILENAME;
}
DatabaseServiceFactory.add(MongoClientFactory.createDatabaseService());
LOG.info("Registering actors to main actor system");
system.actorOf(Props.create(GatewayActor.class), "gateway");
system.actorOf(Props.create(LoginActor.class), "login");
system.actorOf(Props.create(RepositoryActor.class), "repository");
system.actorOf(Props.create(ObjectActor.class), "object");
system.actorOf(Props.create(NavigationActor.class), "navigation");
system.actorOf(Props.create(RelationshipActor.class), "relationships");
system.actorOf(Props.create(PolicyActor.class), "policy");
system.actorOf(Props.create(VersioningActor.class), "versioning");
system.actorOf(Props.create(AclActor.class), "acl");
system.actorOf(Props.create(DiscoveryActor.class), "discovery");
LOG.info("Initializing service factory instances");
try {
boolean factory = createServiceFactory(sce, configFilename);
if (!factory) {
throw new IllegalArgumentException("Repository manager class not initilaized");
}
} catch (Exception e) {
LOG.error("Service factory couldn't be created: {}", e.toString(), e);
}
if (externalActorClassMap != null && !externalActorClassMap.isEmpty()) {
externalActorClassMap.forEach((key, value) -> system.actorOf(Props.create(key), value));
}
if (Helpers.isPerfMode()) {
ConsoleReporter reporter = ConsoleReporter.forRegistry(MetricsInputs.get().getMetrics()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
reporter.start(10, TimeUnit.SECONDS);
if (Helpers.isPrometheusMode()) {
MetricsInputs.collectorRegistry().register(new DropwizardExports(MetricsInputs.get().getMetrics()));
}
}
}
Aggregations