use of com.codahale.metrics.jmx.JmxReporter in project LogHub by fbacchella.
the class Start method launch.
public void launch(Properties props) throws ConfigException, IOException {
for (Source s : props.sources.values()) {
if (!s.configure(props)) {
logger.error("failed to start source {}", s.getName());
throw new IllegalStateException();
}
;
}
props.pipelines.stream().forEach(i -> i.configure(props));
for (Sender s : props.senders) {
if (s.configure(props)) {
s.start();
} else {
logger.error("failed to configure output {}", s.getName());
throw new IllegalStateException();
}
;
}
for (int i = 0; i < props.numWorkers; i++) {
Thread t = new EventsProcessor(props.mainQueue, props.outputQueues, props.namedPipeLine, props.maxSteps, props.repository);
t.setName("ProcessingThread" + i);
t.setDaemon(false);
t.start();
}
for (Receiver r : props.receivers) {
if (r.configure(props)) {
r.start();
} else {
logger.error("failed to configure input {}", r.getName());
throw new IllegalStateException();
}
}
try {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.registerMBean(new StatsMBean.Implementation(), StatsMBean.Implementation.NAME);
JmxReporter reporter = Properties.metrics.getJmxReporter();
reporter.start();
mbs.queryNames(ObjectName.getInstance("metrics", "name", "Pipeline.*.timer"), null).stream().map(i -> i.getKeyProperty("name")).map(i -> i.replaceAll("^Pipeline\\.(.*)\\.timer$", "$1")).forEach(i -> {
try {
mbs.registerMBean(new PipelineStat.Implementation(i), null);
} catch (NotCompliantMBeanException | InstanceAlreadyExistsException | MBeanRegistrationException e) {
}
});
int port = props.jmxport;
if (port > 0) {
Helper.start(props.jmxproto, props.jmxlisten, port);
}
} catch (IOException | NotBoundException | NotCompliantMBeanException | MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException e) {
throw new RuntimeException("jmx configuration failed: " + e.getMessage(), e);
}
if (props.httpPort >= 0) {
AbstractHttpServer server = new DashboardHttpServer();
server.setPort(props.httpPort);
server.configure(props);
}
}
use of com.codahale.metrics.jmx.JmxReporter in project cxf by apache.
the class CodahaleMetricsProvider method setupJMXReporter.
public static void setupJMXReporter(Bus b, MetricRegistry reg) {
InstrumentationManager im = b.getExtension(InstrumentationManager.class);
if (im != null) {
JmxReporter reporter = JmxReporter.forRegistry(reg).registerWith(im.getMBeanServer()).inDomain("org.apache.cxf").createsObjectNamesWith(new ObjectNameFactory() {
public ObjectName createName(String type, String domain, String name) {
try {
return new ObjectName(name);
} catch (MalformedObjectNameException e) {
throw new RuntimeException(e);
}
}
}).build();
reporter.start();
}
}
use of com.codahale.metrics.jmx.JmxReporter in project wikidata-query-rdf by wikimedia.
the class Update method createMetricRegistry.
private static MetricRegistry createMetricRegistry(Closer closer, String metricDomain) {
MetricRegistry metrics = new MetricRegistry();
JmxReporter reporter = closer.register(JmxReporter.forRegistry(metrics).inDomain(metricDomain).build());
reporter.start();
return metrics;
}
use of com.codahale.metrics.jmx.JmxReporter in project wikidata-query-rdf by wikimedia.
the class WikibaseContextListener method createMetricRegistry.
private MetricRegistry createMetricRegistry() {
MetricRegistry registry = new MetricRegistry();
JmxReporter jmxReporter = JmxReporter.forRegistry(registry).inDomain(METRICS_DOMAIN).build();
jmxReporter.start();
shutdownHooks.add(jmxReporter::stop);
return registry;
}
use of com.codahale.metrics.jmx.JmxReporter in project wikidata-query-rdf by wikimedia.
the class StreamingUpdate method main.
public static void main(String[] args) {
log.info("Starting StreamingUpdater");
StreamingUpdateOptions options = OptionsUtils.handleOptions(StreamingUpdateOptions.class, args);
MetricRegistry metrics = new MetricRegistry();
JmxReporter reporter = JmxReporter.forRegistry(metrics).inDomain(options.metricDomain()).build();
StreamingUpdaterConsumer updater = build(options, metrics);
Thread streamingUpdaterThread = Thread.currentThread();
streamingUpdaterThread.setUncaughtExceptionHandler((t, e) -> log.error("Uncaught exception in the updater thread: ", e));
addShutdownHook(updater, streamingUpdaterThread, reporter);
reporter.start();
updater.run();
}
Aggregations