com.codahale.metrics.JmxReporter Java Examples

The following examples show how to use com.codahale.metrics.JmxReporter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetricsConfiguration.java    From cubeai with Apache License 2.0 7 votes vote down vote up
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet());
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        Marker metricsMarker = MarkerFactory.getMarker("metrics");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .markWith(metricsMarker)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
Example #2
Source File: MetricsBundleTest.java    From minnal with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldHandlePostMount() {
	bundle.init(container, configuration);
	
	MetricRegistry metricRegistry = mock(MetricRegistry.class);
	JmxReporter jmxReporter = mock(JmxReporter.class);
	GraphiteReporter graphiteReporter = mock(GraphiteReporter.class);
	
	doReturn(metricRegistry).when(bundle).createMetricRegistry();
	doReturn(jmxReporter).when(bundle).createJmxReporter(metricRegistry);
	doReturn(graphiteReporter).when(bundle).createGraphiteReporter(eq(configuration.getGraphiteReporterConfiguration()), eq(metricRegistry));
	
	bundle.postMount(application);
	verify(jmxReporter).start();
	verify(graphiteReporter).start(configuration.getGraphiteReporterConfiguration().getPollPeriodInSecs(), TimeUnit.SECONDS);
}
 
Example #3
Source File: TajoSystemMetrics.java    From tajo with Apache License 2.0 6 votes vote down vote up
public void start() {
  setMetricsReporter(metricsGroupName);

  final String jvmMetricsName = metricsGroupName + "-JVM";
  setMetricsReporter(jvmMetricsName);

  if(!inited) {
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "MEMORY"), new MemoryUsageGaugeSet());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "FILE"), new FileDescriptorRatioGauge());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "GC"), new GarbageCollectorMetricSet());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "THREAD"), new ThreadStatesGaugeSet());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "LOG"), new LogEventGaugeSet());
    jmxReporter = JmxReporter.forRegistry(metricRegistry).inDomain("Tajo")
            .createsObjectNamesWith(new TajoJMXObjectNameFactory()).build();
    jmxReporter.start();
  }
  inited = true;
}
 
Example #4
Source File: CodahaleMetricsMixin.java    From attic-polygene-java with Apache License 2.0 6 votes vote down vote up
@Override
public void activateService() {
    metricRegistry = new MetricRegistry();
    healthCheckRegistry = new HealthCheckRegistry();
    CodahaleMetricsDeclaration declaration = descriptor.metaInfo( CodahaleMetricsDeclaration.class );
    prefix = declaration.prefix() != null ? declaration.prefix() : app.name();
    fqcn = declaration.fqcn();
    if( declaration.jmx() )
    {
        JmxReporter jmxReporter = JmxReporter.forRegistry( metricRegistry ).build();
        jmxReporter.start();
        reporters.add( jmxReporter );
    }
    for( Function<MetricRegistry, Reporter> reporterFactory : declaration.reportersFactories())
    {
        reporters.add( reporterFactory.apply( metricRegistry ) );
    }
}
 
Example #5
Source File: Main.java    From myriad with Apache License 2.0 6 votes vote down vote up
@Override
public void run(MyriadConfiguration cfg, Environment env) {
	MyriadModule myriadModule = new MyriadModule(cfg);
	Injector injector = Guice.createInjector(myriadModule);

	if (LOGGER.isDebugEnabled()) {
		LOGGER.debug("Bindings: " + injector.getAllBindings());
	}

	JmxReporter.forRegistry(env.metrics()).build().start();
	registerManaged(cfg, env, injector);

	registerResources(cfg, env, injector);
	initHealthChecks(cfg, env, injector);
	initProfiles(cfg, env, injector);
	initRebalancerService(cfg, env, injector);
	initTerminatorService(cfg, env, injector);
}
 
Example #6
Source File: JmxReporterStarter.java    From fluo with Apache License 2.0 6 votes vote down vote up
@Override
public List<AutoCloseable> start(Params params) {
  SimpleConfiguration config =
      new FluoConfiguration(params.getConfiguration()).getReporterConfiguration("jmx");

  if (!config.getBoolean("enable", false)) {
    return Collections.emptyList();
  }

  TimeUnit rateUnit = TimeUnit.valueOf(config.getString("rateUnit", "seconds").toUpperCase());
  TimeUnit durationUnit =
      TimeUnit.valueOf(config.getString("durationUnit", "milliseconds").toUpperCase());

  JmxReporter reporter =
      JmxReporter.forRegistry(params.getMetricRegistry()).convertDurationsTo(durationUnit)
          .convertRatesTo(rateUnit).inDomain(params.getDomain()).build();
  reporter.start();

  log.info("Reporting metrics to JMX");

  return Collections.singletonList((AutoCloseable) reporter);
}
 
Example #7
Source File: MetricsConfiguration.java    From cubeai with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet());
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        Marker metricsMarker = MarkerFactory.getMarker("metrics");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .markWith(metricsMarker)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
Example #8
Source File: MetricsConfiguration.java    From cubeai with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet());
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        Marker metricsMarker = MarkerFactory.getMarker("metrics");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .markWith(metricsMarker)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
Example #9
Source File: MetricsFactoryImpl.java    From usergrid with Apache License 2.0 6 votes vote down vote up
@Inject
public MetricsFactoryImpl(MetricsFig metricsFig) {
    registry = new MetricRegistry();
    String metricsHost = metricsFig.getHost();
    if (!metricsHost.equals("false")) {
        Graphite graphite = new Graphite(new InetSocketAddress(metricsHost, 2003));
        graphiteReporter = GraphiteReporter.forRegistry(registry).prefixedWith("usergrid-metrics")
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL)
            .build(graphite);
        graphiteReporter.start(30, TimeUnit.SECONDS);
    } else {
        logger.warn("MetricsService:Logger not started.");
    }

    jmxReporter = JmxReporter.forRegistry(registry).build();
    jmxReporter.start();
}
 
Example #10
Source File: MetricsConfiguration.java    From cubeai with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet());
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        Marker metricsMarker = MarkerFactory.getMarker("metrics");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .markWith(metricsMarker)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
Example #11
Source File: JmxReportingTest.java    From metrics-sql with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws SQLException {
    mBeanServer=ManagementFactory.getPlatformMBeanServer();
    metricRegistry = new MetricRegistry();
    jmxReporter = JmxReporter.forRegistry(metricRegistry)
            .registerWith(mBeanServer)
            .createsObjectNamesWith(new SqlObjectNameFactory())
            .build();
    jmxReporter.start();
    proxyFactory = new JdbcProxyFactory(metricRegistry);
    rawDataSource = H2DbUtil.createDataSource();
    try(Connection connection = rawDataSource.getConnection()) {
        H2DbUtil.initTable(connection);
    }
    dataSource = proxyFactory.wrapDataSource(rawDataSource);
}
 
Example #12
Source File: MetricsManager.java    From emissary with Apache License 2.0 6 votes vote down vote up
protected void initJmxReporter() {
    if (!this.conf.findBooleanEntry("JMX_METRICS_ENABLED", false)) {
        logger.debug("JMX Metrics are disabled");
        return;
    }

    logger.debug("JMX Metrics are enabled");

    final String domain = this.conf.findStringEntry("JMX_METRICS_DOMAIN", "emissary-metrics");
    final TimeUnit rateUnit = TimeUnit.valueOf(this.conf.findStringEntry("JMX_METRICS_RATE_UNIT", TimeUnit.SECONDS.name()));
    final TimeUnit durationUnit = TimeUnit.valueOf(this.conf.findStringEntry("JMX_METRICS_DURATION_UNIT", TimeUnit.MILLISECONDS.name()));


    final JmxReporter jmxReporter =
            JmxReporter.forRegistry(this.metrics).inDomain(domain).convertRatesTo(rateUnit).convertDurationsTo(durationUnit).build();

    jmxReporter.start();
}
 
Example #13
Source File: MonetaSpringBootApplication.java    From moneta with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
	SpringApplication.run(MonetaSpringBootApplication.class, args);

	// Find and read application configuration
	MonetaConfiguration config = new MonetaConfiguration();

	// Install all health checks
	HealthCheckRegistry registry = new HealthCheckRegistry();
	for (String checkName : MonetaEnvironment.getConfiguration()
			.getHealthChecks()
			.keySet()) {
		registry.register(checkName, MonetaEnvironment.getConfiguration()
				.getHealthChecks()
				.get(checkName));
	}
	ActuatorHealthIndicator.setHealthCheckRegistry(registry);

	// Install metrics and JMX
	MetricRegistry metricRegistry = new MetricRegistry();
	final JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry)
			.build();
	jmxReporter.start();
}
 
Example #14
Source File: ExecutionContainerModule.java    From flux with Apache License 2.0 6 votes vote down vote up
@Named("ExecutionAPIResourceConfig")
@Provides
@Singleton
public ResourceConfig getAPIResourceConfig(ExecutionApiResource executionApiResource, DeploymentUnitResource deploymentUnitResource,
                                           StatusResource statusResource, MetricRegistry metricRegistry) {
    ResourceConfig resourceConfig = new ResourceConfig();

    resourceConfig.register(new InstrumentedResourceMethodApplicationListener(metricRegistry));
    JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();

    resourceConfig.register(executionApiResource);
    resourceConfig.register(deploymentUnitResource);
    resourceConfig.register(statusResource);

    resourceConfig.register(CORSFilter.class);
    jmxReporter.start();
    return resourceConfig;
}
 
Example #15
Source File: StartReportingMetricsToJMXBuilder.java    From kite with Apache License 2.0 6 votes vote down vote up
@Override
protected void doNotify(Record notification) {
  for (Object event : Notifications.getLifecycleEvents(notification)) {
    if (event == Notifications.LifecycleEvent.SHUTDOWN) {
      synchronized (REGISTRIES) {
        Map<String, JmxReporter> reporters = REGISTRIES.get(getContext().getMetricRegistry());
        if (reporters != null) {
          JmxReporter reporter = reporters.remove(domain);
          if (reporter != null) {
            reporter.stop();
          }
        }
      }
    }
  }
  super.doNotify(notification);
}
 
Example #16
Source File: SentryMetrics.java    From incubator-sentry with Apache License 2.0 6 votes vote down vote up
public synchronized void initReporting(Reporting reporting) {
  if(!reportingInitialized) {
    switch(reporting) {
      case CONSOLE:
        final ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(SentryMetricsServletContextListener.METRIC_REGISTRY)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        consoleReporter.start(1, TimeUnit.SECONDS);
        break;
      case JMX:
        final JmxReporter jmxReporter = JmxReporter.forRegistry(SentryMetricsServletContextListener.METRIC_REGISTRY)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        jmxReporter.start();
        break;
    }
  }
}
 
Example #17
Source File: MetricsConfiguration.java    From flair-registry with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        Marker metricsMarker = MarkerFactory.getMarker("metrics");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .markWith(metricsMarker)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
Example #18
Source File: MetricsConfiguration.java    From jhipster-microservices-example with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
Example #19
Source File: HermesMetricsRegistry.java    From hermes with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param topic
 * @param partition
 * @return
 */
public static MetricRegistry getMetricRegistryByTP(String topic, int partition) {
	String key = topic + "|" + partition;
	if (!tp_metrics.containsKey(key)) {
		synchronized (tp_metrics) {
			if (!tp_metrics.containsKey(key)) {
				MetricRegistry metricRegistry = new MetricRegistry();
				tp_metrics.put(key, metricRegistry);
				JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).inDomain(key).build();
				reporter.start();
				reporters.put(key, reporter);
			}
		}
	}
	return tp_metrics.get(key);
}
 
Example #20
Source File: HermesMetricsRegistry.java    From hermes with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param topic
 * @param partition
 * @param group
 * @return
 */
public static MetricRegistry getMetricRegistryByTPG(String topic, int partition, String group) {
	String key = topic + "|" + partition + "|" + group;
	if (!tpg_metrics.containsKey(key)) {
		synchronized (tpg_metrics) {
			if (!tpg_metrics.containsKey(key)) {
				MetricRegistry metricRegistry = new MetricRegistry();
				tpg_metrics.put(key, metricRegistry);
				JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).inDomain(key).build();
				reporter.start();
				reporters.put(key, reporter);
			}
		}
	}
	return tpg_metrics.get(key);
}
 
Example #21
Source File: Bireme.java    From bireme with Apache License 2.0 6 votes vote down vote up
/**
 * Start metrics reporter.
 *
 */
protected void startReporter() {
  switch (cxt.conf.reporter) {
    case "console":
      consoleReporter = ConsoleReporter.forRegistry(cxt.register)
                            .convertRatesTo(TimeUnit.SECONDS)
                            .convertDurationsTo(TimeUnit.MILLISECONDS)
                            .build();
      consoleReporter.start(cxt.conf.report_interval, TimeUnit.SECONDS);
      break;
    case "jmx":
      jmxReporter = JmxReporter.forRegistry(cxt.register).build();
      jmxReporter.start();
      break;
    default:
      break;
  }
}
 
Example #22
Source File: MetricsConfiguration.java    From OpenIoE with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }

    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
Example #23
Source File: MetricsConfiguration.java    From gpmr with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }

    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
Example #24
Source File: MetricsConfiguration.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 6 votes vote down vote up
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }

    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
Example #25
Source File: _MetricsConfiguration.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 6 votes vote down vote up
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }

    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
Example #26
Source File: MetricsConfiguration.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 6 votes vote down vote up
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }

    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
Example #27
Source File: MetricsConfiguration.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 6 votes vote down vote up
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }

    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
 
Example #28
Source File: SiddhiStatisticsManager.java    From siddhi with Apache License 2.0 6 votes vote down vote up
public void startReporting() {
    if (reporterName.equalsIgnoreCase("console")) {
        reporter = ConsoleReporter.forRegistry(metricRegistry)
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .build();
        ((ConsoleReporter) reporter).start(interval, TimeUnit.SECONDS);
    } else if (reporterName.equalsIgnoreCase("jmx")) {
        reporter = JmxReporter.forRegistry(metricRegistry)
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .build();
        ((JmxReporter) reporter).start();
    } else {
        throw new UnsupportedOperationException("Only 'ConsoleReporter' and 'JmxReporter' is supported, Reporter " +
                "type '" + reporter.getClass().getName() + "' is not supported");
    }
}
 
Example #29
Source File: StatCollector.java    From oneops with Apache License 2.0 6 votes vote down vote up
public void init() {
  try {
    if (config.isJMXEnabled()) {
      jmxReporter = JmxReporter.forRegistry(metrics).build();
      jmxReporter.start();
    }

    if (config.isAutoShutDown()) {
      autoShutDownScheduler
          .scheduleWithFixedDelay(this::shutDown, delayInSecs, delayInSecs, SECONDS);
    }

    logger.info("Initializing StatCollector file : " + statFileName);
    statChannel = FileChannel.open(Paths.get(statFileName), CREATE, WRITE);
  } catch (IOException e) {
    logger.error("Error while creating stat file " + statFileName, e);
  }
  rsyncFailed = metrics.meter(name(INDUCTOR, "rsyncFailure"));
  woFailed = metrics.meter(name(INDUCTOR, "woFailure"));
  format = new DecimalFormat();
  format.setMaximumFractionDigits(2);
  statScheduler
      .scheduleWithFixedDelay(this::writeStat, delayInSecs, delayInSecs, SECONDS);
}
 
Example #30
Source File: MetricsConfiguration.java    From klask-io with GNU General Public License v3.0 6 votes vote down vote up
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }

    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}