@Override protected MetricRegistry getMetricRegistry() { return MetricRegistryFactory.getRegistry(); } }
MetricRegistry metricRegistry = MetricRegistryFactory.getRegistry(); Map<String, Metric> metrics = metricRegistry.getMetrics();
/** * Create a Codahale metric appender and add to ROOT logger. */ private void registerMetricsAppender() { // Get the root logger LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory(); Logger rootLogger = factory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); // Create the metrics appender and give it the root logger's context InstrumentedAppender appender = new InstrumentedAppender(MetricRegistryFactory.getRegistry()); appender.setContext(rootLogger.getLoggerContext()); appender.start(); // Add the appender to the root logger rootLogger.addAppender(appender); } }
/** * Constructor. * * @throws ClassNotFoundException if a class was not found when attempting to load it * @throws InstantiationException if a class was not able to be instantiated * @throws IllegalAccessException if there was a problem accessing something due to security restrictions */ public ResourceConfig() throws ClassNotFoundException, InstantiationException, IllegalAccessException { // Build the binder using the configured factory Class<?> binderClass = Class.forName(bindingFactory); BinderFactory binderFactory = (BinderFactory) binderClass.newInstance(); Binder binder = binderFactory.buildBinder(); // Register Instrumentation register(new InstrumentedResourceMethodApplicationListener(MetricRegistryFactory.getRegistry())); registerMetricsAppender(); register(binder); registerFilters(); // Call post-registration hook to allow for additional registration binderFactory.afterRegistration(this); }
/** * Create a Codahale metric appender and add to ROOT logger. */ private void registerMetricsAppender() { // Get the root logger LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory(); ch.qos.logback.classic.Logger rootLogger = factory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME); // Create the metrics appender and give it the root logger's context InstrumentedAppender appender = new InstrumentedAppender(MetricRegistryFactory.getRegistry()); appender.setContext(rootLogger.getLoggerContext()); appender.start(); // Add the appender to the root logger rootLogger.addAppender(appender); }
/** * Create a Codahale metric appender and add to ROOT logger. */ private void registerMetricsAppender() { // Get the root logger LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory(); ch.qos.logback.classic.Logger rootLogger = factory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME); // Create the metrics appender and give it the root logger's context InstrumentedAppender appender = new InstrumentedAppender(MetricRegistryFactory.getRegistry()); appender.setContext(rootLogger.getLoggerContext()); appender.start(); // Add the appender to the root logger rootLogger.addAppender(appender); }
this.config.register(new InstrumentedResourceMethodApplicationListener(MetricRegistryFactory.getRegistry())); this.config.register(this.binder);
this.config.register(new InstrumentedResourceMethodApplicationListener(MetricRegistryFactory.getRegistry())); this.config.register(this.binder);