use of com.codahale.metrics.JmxReporter in project newts by OpenNMS.
the class NewtsService method run.
@Override
public void run(final NewtsConfig config, Environment environment) throws Exception {
// Filters
configureCors(environment);
configureUIRedirect(environment);
configureAuthentication(environment, config);
final Injector injector = Guice.createInjector(new NewtsGuiceModule(), new CassandraGuiceModule(config), new GraphiteGuiceModule(config));
MetricRegistry metricRegistry = injector.getInstance(MetricRegistry.class);
// Create/start a JMX reporter for our MetricRegistry
final JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).inDomain("newts").build();
// Create (and start if so configured), a Graphite line-protocol listener
final GraphiteListenerThread listener = new GraphiteListenerThread(injector.getInstance(GraphiteListener.class));
environment.lifecycle().manage(new Managed() {
@Override
public void stop() throws Exception {
reporter.stop();
}
@Override
public void start() throws Exception {
reporter.start();
if (config.getGraphiteConfig().isEnabled()) {
listener.start();
}
}
});
SampleRepository repository = injector.getInstance(SampleRepository.class);
Indexer indexer = injector.getInstance(Indexer.class);
// Rest resources
environment.jersey().register(new MeasurementsResource(repository, config.getReports()));
environment.jersey().register(new SamplesResource(repository, indexer));
// Add search resource only if search is enabled
if (config.getSearchConfig().isEnabled()) {
environment.jersey().register(new SearchResource(injector.getInstance(Searcher.class)));
}
// Health checks
environment.healthChecks().register("repository", new RepositoryHealthCheck(repository));
// Mapped exceptions
environment.jersey().register(IllegalArgumentExceptionMapper.class);
}
use of com.codahale.metrics.JmxReporter in project graylog2-server by Graylog2.
the class CmdLineTool method run.
@Override
public void run() {
final Level logLevel = setupLogger();
final PluginBindings pluginBindings = installPluginConfigAndBindings(getPluginPath(configFile), chainingClassLoader);
if (isDumpDefaultConfig()) {
dumpDefaultConfigAndExit();
}
final NamedConfigParametersModule configModule = readConfiguration(configFile);
if (isDumpConfig()) {
dumpCurrentConfigAndExit();
}
if (!validateConfiguration()) {
LOG.error("Validating configuration file failed - exiting.");
System.exit(1);
}
beforeStart();
final List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
LOG.info("Running with JVM arguments: {}", Joiner.on(' ').join(arguments));
injector = setupInjector(configModule, pluginBindings, binder -> binder.bind(ChainingClassLoader.class).toInstance(chainingClassLoader));
if (injector == null) {
LOG.error("Injector could not be created, exiting! (Please include the previous error messages in bug reports.)");
System.exit(1);
}
// This is holding all our metrics.
final MetricRegistry metrics = injector.getInstance(MetricRegistry.class);
addInstrumentedAppender(metrics, logLevel);
// Report metrics via JMX.
final JmxReporter reporter = JmxReporter.forRegistry(metrics).build();
reporter.start();
startCommand();
}
use of com.codahale.metrics.JmxReporter in project opennms by OpenNMS.
the class KafkaLocalMessageDispatcherFactory method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
final JmxReporter reporter = JmxReporter.forRegistry(getMetrics()).inDomain(KafkaLocalMessageDispatcherFactory.class.getPackage().getName()).build();
reporter.start();
}
Aggregations