com.codahale.metrics.jvm.MemoryUsageGaugeSet Java Examples

The following examples show how to use com.codahale.metrics.jvm.MemoryUsageGaugeSet. 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: Poseidon.java    From Poseidon with Apache License 2.0 6 votes vote down vote up
private ServletContextHandler getMetricsHandler() {
    MetricRegistry registry = Metrics.getRegistry();
    HealthCheckRegistry healthCheckRegistry = Metrics.getHealthCheckRegistry();
    healthCheckRegistry.register("rotation", new Rotation(configuration.getRotationStatusFilePath()));

    registry.registerAll(new GarbageCollectorMetricSet());
    registry.registerAll(new MemoryUsageGaugeSet());
    registry.registerAll(new ThreadStatesGaugeSet());
    registry.registerAll(new JvmAttributeGaugeSet());

    ServletContextHandler servletContextHandler = new ServletContextHandler();
    servletContextHandler.setContextPath("/__metrics");
    servletContextHandler.setAttribute(MetricsServlet.class.getCanonicalName() + ".registry", registry);
    servletContextHandler.setAttribute(HealthCheckServlet.class.getCanonicalName() + ".registry", healthCheckRegistry);
    servletContextHandler.addServlet(new ServletHolder(new AdminServlet()), "/*");

    return servletContextHandler;
}
 
Example #2
Source File: MetricsHelper.java    From lemon with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    /*
     * consoleReporter = ConsoleReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS)
     * .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); consoleReporter.start(1, TimeUnit.SECONDS);
     */
    GarbageCollectorMetricSet gc = new GarbageCollectorMetricSet();

    // FileDescriptorRatioGauge fd = new FileDescriptorRatioGauge();
    MemoryUsageGaugeSet mu = new MemoryUsageGaugeSet();

    // ThreadDeadlockDetector td = new ThreadDeadlockDetector();

    // ThreadDump t = new ThreadDump();
    ThreadStatesGaugeSet ts = new ThreadStatesGaugeSet();

    metricRegistry.register("GarbageCollector", gc);
    // registry.register(FileDescriptorRatioGauge.class.getName(), fd);
    metricRegistry.register("MemoryUsage", mu);
    // registry.register(ThreadDeadlockDetector.class.getName(), td);
    // registry.registerAll(t);
    metricRegistry.register("ThreadStates", ts);
    healthCheckRegistry.register("threadDeadlock",
            new ThreadDeadlockHealthCheck());
}
 
Example #3
Source File: MetricsReportingTaskTest.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Make sure that in a single life cycle the correct metrics are registered, the correct {@link ProcessGroupStatus}
 * is used and that metrics are actually reported.
 */
@Test
public void testValidLifeCycleReportsCorrectlyProcessGroupSpecified() throws Exception {
    reportingContextStub.setProperty(MetricsReportingTask.PROCESS_GROUP_ID.getName(), TEST_GROUP_ID);
    reportingContextStub.getEventAccess().setProcessGroupStatus(TEST_GROUP_ID, innerGroupStatus);

    testedReportingTask.initialize(reportingInitContextStub);
    testedReportingTask.connect(configurationContextStub);
    testedReportingTask.onTrigger(reportingContextStub);
    verify(reporterMock).report();

    // Verify correct metrics are registered
    ArgumentCaptor<MetricRegistry> registryCaptor = ArgumentCaptor.forClass(MetricRegistry.class);
    verify(reporterServiceStub).createReporter(registryCaptor.capture());
    MetricRegistry usedRegistry = registryCaptor.getValue();
    Map<String, Metric> usedMetrics = usedRegistry.getMetrics();
    assertTrue(usedMetrics.keySet().containsAll(new MemoryUsageGaugeSet().getMetrics().keySet()));
    assertTrue(usedMetrics.keySet()
            .containsAll(new FlowMetricSet(testedReportingTask.currentStatusReference).getMetrics().keySet()));

    // Verify the most current ProcessGroupStatus is updated
    assertEquals(testedReportingTask.currentStatusReference.get(), innerGroupStatus);
}
 
Example #4
Source File: MetricsReportingTaskTest.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Make sure that in a single life cycle the correct metrics are registered, the correct {@link ProcessGroupStatus}
 * is used and that metrics are actually reported.
 */
@Test
public void testValidLifeCycleReportsCorrectly() throws Exception {
    reportingContextStub.getEventAccess().setProcessGroupStatus(rootGroupStatus);

    testedReportingTask.initialize(reportingInitContextStub);
    testedReportingTask.connect(configurationContextStub);
    testedReportingTask.onTrigger(reportingContextStub);
    verify(reporterMock).report();

    // Verify correct metrics are registered
    ArgumentCaptor<MetricRegistry> registryCaptor = ArgumentCaptor.forClass(MetricRegistry.class);
    verify(reporterServiceStub).createReporter(registryCaptor.capture());
    MetricRegistry usedRegistry = registryCaptor.getValue();
    Map<String, Metric> usedMetrics = usedRegistry.getMetrics();
    assertTrue(usedMetrics.keySet().containsAll(new MemoryUsageGaugeSet().getMetrics().keySet()));
    assertTrue(usedMetrics.keySet()
            .containsAll(new FlowMetricSet(testedReportingTask.currentStatusReference).getMetrics().keySet()));

    // Verify the most current ProcessGroupStatus is updated
    assertEquals(testedReportingTask.currentStatusReference.get(), rootGroupStatus);
}
 
Example #5
Source File: GetStarted.java    From metrics-zabbix with Apache License 2.0 6 votes vote down vote up
public static void main(String args[]) throws IOException, InterruptedException {
	ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics).convertRatesTo(TimeUnit.SECONDS)
			.convertDurationsTo(TimeUnit.MILLISECONDS).build();
	metrics.register("jvm.mem", new MemoryUsageGaugeSet());
	metrics.register("jvm.gc", new GarbageCollectorMetricSet());
	reporter.start(5, TimeUnit.SECONDS);

	String hostName = "192.168.66.29";
	ZabbixSender zabbixSender = new ZabbixSender("192.168.90.102", 10051);
	ZabbixReporter zabbixReporter = ZabbixReporter.forRegistry(metrics).hostName(hostName).prefix("test.")
			.build(zabbixSender);

	zabbixReporter.start(1, TimeUnit.SECONDS);

	TimeUnit.SECONDS.sleep(500);
}
 
Example #6
Source File: SolrDispatchFilter.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void setupJvmMetrics(CoreContainer coresInit)  {
  metricManager = coresInit.getMetricManager();
  registryName = SolrMetricManager.getRegistryName(SolrInfoBean.Group.jvm);
  final Set<String> hiddenSysProps = coresInit.getConfig().getMetricsConfig().getHiddenSysProps();
  try {
    metricManager.registerAll(registryName, new AltBufferPoolMetricSet(), SolrMetricManager.ResolutionStrategy.IGNORE, "buffers");
    metricManager.registerAll(registryName, new ClassLoadingGaugeSet(), SolrMetricManager.ResolutionStrategy.IGNORE, "classes");
    metricManager.registerAll(registryName, new OperatingSystemMetricSet(), SolrMetricManager.ResolutionStrategy.IGNORE, "os");
    metricManager.registerAll(registryName, new GarbageCollectorMetricSet(), SolrMetricManager.ResolutionStrategy.IGNORE, "gc");
    metricManager.registerAll(registryName, new MemoryUsageGaugeSet(), SolrMetricManager.ResolutionStrategy.IGNORE, "memory");
    metricManager.registerAll(registryName, new ThreadStatesGaugeSet(), SolrMetricManager.ResolutionStrategy.IGNORE, "threads"); // todo should we use CachedThreadStatesGaugeSet instead?
    MetricsMap sysprops = new MetricsMap((detailed, map) -> {
      System.getProperties().forEach((k, v) -> {
        if (!hiddenSysProps.contains(k)) {
          map.put(String.valueOf(k), v);
        }
      });
    });
    metricManager.registerGauge(null, registryName, sysprops, metricTag, true, "properties", "system");
  } catch (Exception e) {
    log.warn("Error registering JVM metrics", e);
  }
}
 
Example #7
Source File: CloudWatchReporter.java    From codahale-aggregated-metrics-cloudwatch-reporter with MIT License 6 votes vote down vote up
public CloudWatchReporter build() {

            if (withJvmMetrics) {
                metricRegistry.register("jvm.uptime", (Gauge<Long>) () -> ManagementFactory.getRuntimeMXBean().getUptime());
                metricRegistry.register("jvm.current_time", (Gauge<Long>) clock::getTime);
                metricRegistry.register("jvm.classes", new ClassLoadingGaugeSet());
                metricRegistry.register("jvm.fd_usage", new FileDescriptorRatioGauge());
                metricRegistry.register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
                metricRegistry.register("jvm.gc", new GarbageCollectorMetricSet());
                metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet());
                metricRegistry.register("jvm.thread-states", new ThreadStatesGaugeSet());
            }

            cwRateUnit = cwMeterUnit.orElse(toStandardUnit(rateUnit));
            cwDurationUnit = toStandardUnit(durationUnit);

            return new CloudWatchReporter(this);
        }
 
Example #8
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 #9
Source File: TajoSystemMetrics.java    From incubator-tajo with Apache License 2.0 5 votes vote down vote up
public void start() {
  setMetricsReporter(metricsGroupName);

  String jvmMetricsName = metricsGroupName + "-jvm";
  setMetricsReporter(jvmMetricsName);

  if(!inited) {
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "Heap"), 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());
  }
  inited = true;
}
 
Example #10
Source File: StreamSortHandlerTest.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    final MetricRegistry metrics = new MetricRegistry();
    metrics.registerAll(new MemoryUsageGaugeSet());
    metrics.registerAll(new GarbageCollectorMetricSet());
    metricReporter = Slf4jReporter.forRegistry(metrics)
        .filter((name, metric) -> name.matches("(.*heap|pools.PS.*).usage"))
        .withLoggingLevel(Slf4jReporter.LoggingLevel.DEBUG)
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.MILLISECONDS)
        .build();
    metricReporter.start(60, TimeUnit.SECONDS);
}
 
Example #11
Source File: StreamWindowBenchmarkTest.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Before
    public void setUp() {
        final MetricRegistry metrics = new MetricRegistry();
        metrics.registerAll(new MemoryUsageGaugeSet());
        metrics.registerAll(new GarbageCollectorMetricSet());
        metricReporter = ConsoleReporter.forRegistry(metrics)
            .filter((name, metric) -> name.matches("(.*heap|total).(usage|used)"))
//                .withLoggingLevel(Slf4jReporter.LoggingLevel.DEBUG)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        metricReporter.start(60, TimeUnit.SECONDS);
        performanceReport = new TreeMap<>();
    }
 
Example #12
Source File: MemoryUsageGaugeSetTest.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Test
public void testJVMMetrics() throws InterruptedException {
    LOG.info("Starting testJVMMetrics");
    final MetricRegistry metrics = new MetricRegistry();
    ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics)
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.MILLISECONDS)
        .build();
    metrics.registerAll(new MemoryUsageGaugeSet());
    metrics.register("sample", (Gauge<Double>) () -> 0.1234);
    reporter.start(1, TimeUnit.SECONDS);
    reporter.close();
}
 
Example #13
Source File: MetricsModule.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Provides @Singleton MetricRegistry provideMetrics() {
  MetricRegistry metrics = new MetricRegistry();
  metrics.register("jvm.memory", new MemoryUsageGaugeSet());
  metrics.register("jvm.garbage", new GarbageCollectorMetricSet());
  metrics.register("jvm.threads", new ThreadStatesGaugeSet());
  metrics.register("jvm.files", new FileDescriptorRatioGauge());
  metrics.register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  return metrics;
}
 
Example #14
Source File: StreamingMetrics.java    From kylin with Apache License 2.0 5 votes vote down vote up
/**
 * ThreadStatesGaugeSet & ClassLoadingGaugeSet are currently not registered.
 * metricRegistry.register("threads", new ThreadStatesGaugeSet());
 */
private StreamingMetrics() {
    if (METRICS_OPTION != null && !METRICS_OPTION.isEmpty()) {
        metricRegistry.register("gc", new GarbageCollectorMetricSet());
        metricRegistry.register("threads", new CachedThreadStatesGaugeSet(10, TimeUnit.SECONDS));
        metricRegistry.register("memory", new MemoryUsageGaugeSet());
    }
}
 
Example #15
Source File: DropWizardJVMMetrics.java    From james-project with Apache License 2.0 5 votes vote down vote up
public void start() {
    metricRegistry.register("jvm.file.descriptor", new FileDescriptorRatioGauge());
    metricRegistry.register("jvm.gc", new GarbageCollectorMetricSet());
    metricRegistry.register("jvm.threads", new ThreadStatesGaugeSet());
    metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet());
    metricRegistry.register("jvm.class.loading", new ClassLoadingGaugeSet());
}
 
Example #16
Source File: DefaultMetricsService.java    From knox with Apache License 2.0 5 votes vote down vote up
private void registerJvmMetricSets() {
  metrics.registerAll(new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  metrics.registerAll(new CachedThreadStatesGaugeSet(5, TimeUnit.MINUTES));
  metrics.registerAll(new ClassLoadingGaugeSet());
  metrics.registerAll(new GarbageCollectorMetricSet());
  metrics.registerAll(new JvmAttributeGaugeSet());
  metrics.registerAll(new MemoryUsageGaugeSet());
}
 
Example #17
Source File: RegisterJVMMetricsBuilder.java    From kite with Apache License 2.0 5 votes vote down vote up
public RegisterJVMMetrics(CommandBuilder builder, Config config, Command parent, 
                                   Command child, final MorphlineContext context) {
  
  super(builder, config, parent, child, context);      
  validateArguments();
  
  MetricRegistry registry = context.getMetricRegistry();
  BufferPoolMetricSet bufferPoolMetrics = new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer());
  registerAll("jvm.buffers", bufferPoolMetrics, registry);
  registerAll("jvm.gc", new GarbageCollectorMetricSet(), registry);
  registerAll("jvm.memory", new MemoryUsageGaugeSet(), registry);
  registerAll("jvm.threads", new ThreadStatesGaugeSet(), registry);
  register("jvm.fileDescriptorCountRatio", new FileDescriptorRatioGauge(), registry);
  context.getHealthCheckRegistry().register("deadlocks", new ThreadDeadlockHealthCheck());
}
 
Example #18
Source File: JMXReportingService.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private void registerJvmMetrics() {
  registerMetricSetWithPrefix("jvm.gc", new GarbageCollectorMetricSet());
  registerMetricSetWithPrefix("jvm.memory", new MemoryUsageGaugeSet());
  registerMetricSetWithPrefix("jvm.threads", new ThreadStatesGaugeSet());
  this.metricRegistry.register("jvm.fileDescriptorRatio", new FileDescriptorRatioGauge());
  for (Map.Entry<String, MetricSet> metricSet : this.additionalMetricSets.entrySet()) {
    registerMetricSetWithPrefix(metricSet.getKey(), metricSet.getValue());
  }
}
 
Example #19
Source File: MetricsConfiguration.java    From chassis with Apache License 2.0 5 votes vote down vote up
/***
    * Initializes the metrics registry
    *
    * @return metric registry bean
    */
@Bean
public MetricRegistry metricRegistry() {
	final MetricRegistry bean = new MetricRegistry();

       // add JVM metrics
	bean.register("jvm.gc", new GarbageCollectorMetricSet());
	bean.register("jvm.memory", new MemoryUsageGaugeSet());
	bean.register("jvm.thread-states", new ThreadStatesGaugeSet());
	bean.register("jvm.fd", new FileDescriptorRatioGauge());

	return bean;
}
 
Example #20
Source File: ChassisConfiguration.java    From chassis with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the metrics registry
 *
 * @return metric registry bean
 */
@Bean
public MetricRegistry metricRegistry() {
    final MetricRegistry bean = new MetricRegistry();

    // add JVM metrics
    bean.register("jvm.gc", new GarbageCollectorMetricSet());
    bean.register("jvm.memory", new MemoryUsageGaugeSet());
    bean.register("jvm.thread-states", new ThreadStatesGaugeSet());
    bean.register("jvm.fd", new FileDescriptorRatioGauge());
    bean.register("jvm.load-average", new Gauge<Double>() {
        private OperatingSystemMXBean mxBean = ManagementFactory.getOperatingSystemMXBean();

        public Double getValue() {
            try {
                return mxBean.getSystemLoadAverage();
            } catch (Exception e) {
                // not supported
                return -1d;
            }
        }
    });

    // add Logback metrics
    final LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory();
    final Logger root = factory.getLogger(Logger.ROOT_LOGGER_NAME);
    final InstrumentedAppender appender = new InstrumentedAppender(bean);
    appender.setContext(root.getLoggerContext());
    appender.start();
    root.addAppender(appender);

    return bean;
}
 
Example #21
Source File: CollectorMetric.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
private void initRegistry() {
    // add JVM statistics
    metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet());
    metricRegistry.register("jvm.vm", new JvmAttributeGaugeSet());
    metricRegistry.register("jvm.garbage-collectors", new GarbageCollectorMetricSet());
    metricRegistry.register("jvm.thread-states", new ThreadStatesGaugeSet());

    if (hBaseAsyncOperationMetrics != null) {
        Map<String, Metric> metrics = hBaseAsyncOperationMetrics.getMetrics();
        for (Map.Entry<String, Metric> metric : metrics.entrySet()) {
            metricRegistry.register(metric.getKey(), metric.getValue());
        }
    }
}
 
Example #22
Source File: JmxJvmMetrics.java    From nifi with Apache License 2.0 5 votes vote down vote up
public static JmxJvmMetrics getInstance() {
    if (metricRegistry.get() == null) {
        metricRegistry.set(new MetricRegistry());
        metricRegistry.get().register(REGISTRY_METRICSET_JVM_ATTRIBUTES, new JvmAttributeGaugeSet());
        metricRegistry.get().register(REGISTRY_METRICSET_MEMORY, new MemoryUsageGaugeSet());
        metricRegistry.get().register(REGISTRY_METRICSET_THREADS, new ThreadStatesGaugeSet());
        metricRegistry.get().register(REGISTRY_METRICSET_GARBAGE_COLLECTORS, new GarbageCollectorMetricSet());
        metricRegistry.get().register(OS_FILEDESCRIPTOR_USAGE, new FileDescriptorRatioGauge());

    }
    return new JmxJvmMetrics();
}
 
Example #23
Source File: MetricsReportingTask.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Register all wanted metrics to {@link #metricRegistry}.
 * <p>
 * {@inheritDoc}
 */
@Override
protected void init(ReportingInitializationContext config) {
    metricRegistry = new MetricRegistry();
    currentStatusReference = new AtomicReference<>();
    metricRegistry.registerAll(new MemoryUsageGaugeSet());
    metricRegistry.registerAll(new FlowMetricSet(currentStatusReference));
}
 
Example #24
Source File: SentryMetrics.java    From incubator-sentry with Apache License 2.0 5 votes vote down vote up
private SentryMetrics() {
  registerMetricSet("gc", new GarbageCollectorMetricSet(), SentryMetricsServletContextListener.METRIC_REGISTRY);
  registerMetricSet("buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()),
      SentryMetricsServletContextListener.METRIC_REGISTRY);
  registerMetricSet("memory", new MemoryUsageGaugeSet(), SentryMetricsServletContextListener.METRIC_REGISTRY);
  registerMetricSet("threads", new ThreadStatesGaugeSet(), SentryMetricsServletContextListener.METRIC_REGISTRY);
}
 
Example #25
Source File: DrillMetrics.java    From Bats with Apache License 2.0 5 votes vote down vote up
private static void registerSystemMetrics() {
  REGISTRY.registerAll(new GarbageCollectorMetricSet());
  REGISTRY.registerAll(new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  REGISTRY.registerAll(new MemoryUsageGaugeSet());
  REGISTRY.registerAll(new ThreadStatesGaugeSet());
  REGISTRY.registerAll(new CpuGaugeSet());
  register("fd.usage", new FileDescriptorRatioGauge());
}
 
Example #26
Source File: LocalDataTransferServer.java    From rubix with Apache License 2.0 5 votes vote down vote up
/**
 * Register desired metrics.
 *
 * @param conf The current Hadoop configuration.
 */
private static void registerMetrics(Configuration conf)
{
  bookKeeperMetrics = new BookKeeperMetrics(conf, metrics);

  metrics.register(BookKeeperMetrics.LDTSJvmMetric.LDTS_JVM_GC_PREFIX.getMetricName(), new GarbageCollectorMetricSet());
  metrics.register(BookKeeperMetrics.LDTSJvmMetric.LDTS_JVM_THREADS_PREFIX.getMetricName(), new CachedThreadStatesGaugeSet(CacheConfig.getMetricsReportingInterval(conf), TimeUnit.MILLISECONDS));
  metrics.register(BookKeeperMetrics.LDTSJvmMetric.LDTS_JVM_MEMORY_PREFIX.getMetricName(), new MemoryUsageGaugeSet());
}
 
Example #27
Source File: MetricsConfiguration.java    From flair-engine with Apache License 2.0 5 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 (hikariDataSource != null) {
        log.debug("Monitoring the datasource");
        hikariDataSource.setMetricRegistry(metricRegistry);
    }
    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: StreamingMetrics.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * ThreadStatesGaugeSet & ClassLoadingGaugeSet are currently not registered.
 * metricRegistry.register("threads", new ThreadStatesGaugeSet());
 */
private StreamingMetrics() {
    if (METRICS_OPTION != null && !METRICS_OPTION.isEmpty()) {
        metricRegistry.register("gc", new GarbageCollectorMetricSet());
        metricRegistry.register("threads", new CachedThreadStatesGaugeSet(10, TimeUnit.SECONDS));
        metricRegistry.register("memory", new MemoryUsageGaugeSet());
    }
}
 
Example #29
Source File: MetricsManager.java    From emissary with Apache License 2.0 5 votes vote down vote up
protected void initMetrics() {
    if (this.conf.findBooleanEntry("JVM_METRICS_ENABLED", false)) {
        logger.debug("JVM Metrics are enabled");
        this.metrics.registerAll(new MemoryUsageGaugeSet());
        this.metrics.registerAll(new GarbageCollectorMetricSet());
        this.metrics.registerAll(new ThreadStatesGaugeSet());
        this.metrics.register("file.descriptor.info", new FileDescriptorRatioGauge());
    } else {
        logger.debug("JVM Metrics are disabled");
    }
}
 
Example #30
Source File: JVMMetrics.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
static void addJvmMetrics(MetricRegistries registries) {
  MetricRegistryInfo info = new MetricRegistryInfo("jvm", "ratis_jvm", "jvm", "jvm metrics");

  RatisMetricRegistry registry = registries.create(info);

  registry.registerAll("gc", new GarbageCollectorMetricSet());
  registry.registerAll("memory", new MemoryUsageGaugeSet());
  registry.registerAll("threads", new ThreadStatesGaugeSet());
  registry.registerAll("classLoading", new ClassLoadingGaugeSet());
}