use of com.codahale.metrics.JmxReporter in project hive by apache.
the class CodahaleMetrics method initReporting.
/**
* Should be only called once to initialize the reporters
*/
private void initReporting(Set<MetricsReporting> reportingSet) {
for (MetricsReporting reporting : reportingSet) {
switch(reporting) {
case CONSOLE:
final ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
consoleReporter.start(1, TimeUnit.SECONDS);
reporters.add(consoleReporter);
break;
case JMX:
final JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
jmxReporter.start();
reporters.add(jmxReporter);
break;
case JSON_FILE:
final JsonFileReporter jsonFileReporter = new JsonFileReporter();
jsonFileReporter.start();
reporters.add(jsonFileReporter);
break;
case HADOOP2:
String applicationName = conf.get(HiveConf.ConfVars.HIVE_METRICS_HADOOP2_COMPONENT_NAME.varname);
long reportingInterval = HiveConf.toTime(conf.get(HiveConf.ConfVars.HIVE_METRICS_HADOOP2_INTERVAL.varname), TimeUnit.SECONDS, TimeUnit.SECONDS);
final HadoopMetrics2Reporter metrics2Reporter = HadoopMetrics2Reporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build(// The application-level name
DefaultMetricsSystem.initialize(applicationName), // Component name
applicationName, // Component description
applicationName, // Name for each metric record
"General");
metrics2Reporter.start(reportingInterval, TimeUnit.SECONDS);
break;
}
}
}
use of com.codahale.metrics.JmxReporter in project sockjs-netty by cgbystrom.
the class StressTestServer method start.
public void start() throws Exception {
final JmxReporter reporter = JmxReporter.forRegistry(registry).build();
final ServiceRouter router = new ServiceRouter();
reporter.start();
router.setMetricRegistry(registry);
Service echoService = new Service("/stresstest", new SessionCallbackFactory() {
@Override
public StressTestSession getSession(String id) throws Exception {
return new StressTestSession();
}
});
router.registerService(echoService);
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
// Required for WS handshaker or else NPE.
pipeline.addLast("chunkAggregator", new HttpChunkAggregator(130 * 1024));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("preflight", new PreflightHandler());
pipeline.addLast("router", router);
return pipeline;
}
});
bootstrap.bind(new LocalAddress(port));
}
use of com.codahale.metrics.JmxReporter in project sockjs-netty by cgbystrom.
the class TestServer method main.
public static void main(String[] args) {
Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
LoggerContext loggerContext = rootLogger.getLoggerContext();
loggerContext.reset();
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(loggerContext);
encoder.setPattern("%-5level %-20class{0}: %message%n");
encoder.start();
ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
appender.setContext(loggerContext);
appender.setEncoder(encoder);
appender.start();
rootLogger.addAppender(appender);
InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
final MetricRegistry registry = new MetricRegistry();
final JmxReporter reporter = JmxReporter.forRegistry(registry).build();
reporter.start();
final ServiceRouter router = new ServiceRouter();
router.setMetricRegistry(registry);
router.registerService(new Service("/disabled_websocket_echo", new DisabledWebSocketEchoSession()));
router.registerService(new Service("/close", new CloseSession()));
router.registerService(new Service("/amplify", new AmplifySession()));
router.registerService(new Service("/broadcast", new SessionCallbackFactory() {
@Override
public BroadcastSession getSession(String id) throws Exception {
return new BroadcastSession();
}
}));
Service echoService = new Service("/echo", new SessionCallbackFactory() {
@Override
public EchoSession getSession(String id) throws Exception {
return new EchoSession();
}
});
echoService.setMaxResponseSize(4096);
router.registerService(echoService);
Service cookieNeededEcho = new Service("/cookie_needed_echo", new EchoSession());
cookieNeededEcho.setMaxResponseSize(4096);
cookieNeededEcho.setCookieNeeded(true);
router.registerService(cookieNeededEcho);
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
// Required for WS handshaker or else NPE.
pipeline.addLast("chunkAggregator", new HttpChunkAggregator(130 * 1024));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("preflight", new PreflightHandler());
pipeline.addLast("router", router);
return pipeline;
}
});
bootstrap.bind(new InetSocketAddress(8090));
System.out.println("Server running..");
}
use of com.codahale.metrics.JmxReporter in project opennms by OpenNMS.
the class CamelLocalMessageDispatcherFactory method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
final JmxReporter reporter = JmxReporter.forRegistry(getMetrics()).inDomain(CamelLocalMessageDispatcherFactory.class.getPackage().getName()).build();
reporter.start();
}
use of com.codahale.metrics.JmxReporter in project ninja by ninjaframework.
the class MetricsServiceImpl method start.
@Start(order = 10)
@Override
public void start() {
String applicationName = ninjaProps.getWithDefault(NinjaConstant.applicationName, "Ninja");
/*
* Register optional metrics
*/
if (ninjaProps.getBooleanWithDefault("metrics.jvm.enabled", false)) {
registerAll("jvm.gc", new GarbageCollectorMetricSet());
registerAll("jvm.memory", new MemoryUsageGaugeSet());
registerAll("jvm.threads", new ThreadStatesGaugeSet());
registerAll("jvm.classes", new ClassLoadingGaugeSet());
log.debug("Registered JVM-Metrics integration");
}
if (ninjaProps.getBooleanWithDefault("metrics.logback.enabled", false)) {
final LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory();
final ch.qos.logback.classic.Logger root = factory.getLogger(Logger.ROOT_LOGGER_NAME);
final InstrumentedAppender appender = new InstrumentedAppender(metricRegistry);
appender.setContext(root.getLoggerContext());
appender.start();
root.addAppender(appender);
log.debug("Registered Logback-Metrics integration");
}
/*
* MBeans for VisualVM, JConsole, or JMX
*/
if (ninjaProps.getBooleanWithDefault("metrics.mbeans.enabled", true)) {
JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).inDomain(applicationName).build();
reporter.start();
reporters.add(reporter);
log.debug("Started Ninja Metrics MBeans reporter");
}
log.info("Ninja Metrics is ready for collection.");
}
Aggregations