Java 类com.codahale.metrics.jvm.GarbageCollectorMetricSet 实例源码

项目:Poseidon    文件:Poseidon.java   
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;
}
项目:lemon    文件:MetricsHelper.java   
@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());
}
项目:JInsight    文件:JvmMetricSet.java   
public JvmMetricSet() {
  registerSet("jvm.buffers", new BufferPoolMetricSet(getPlatformMBeanServer()));
  registerSet("jvm.classloading", new ClassLoadingGaugeSet());
  registerSet("jvm.fd", new FileDescriptorMetrics());
  registerSet("jvm.gc", new GarbageCollectorMetricSet());
  registerSet("jvm.memory", new MemoryUsageGaugeSet());
  registerSet("jvm.thread", new CachedThreadStatesGaugeSet(60, TimeUnit.SECONDS));

  metrics.put("jvm.uptime", new UptimeGauge());

  try {
    metrics.put("jvm.processCPU", new ProcessCpuTicksGauge());
  } catch (ClassNotFoundException | IOException e) {
    LOGGER.error("Error fetching process CPU usage metrics.", e);
  }
}
项目:codahale-aggregated-metrics-cloudwatch-reporter    文件:CloudWatchReporter.java   
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 = toStandardUnit(rateUnit);
            cwDurationUnit = toStandardUnit(durationUnit);

            return new CloudWatchReporter(this);
        }
项目:it-keeps    文件:MetricsFactory.java   
public static void enableJvm() {

        if (bEnableJvm)
            return;

        METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
        METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
        METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
        METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
        METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_BUFFERS,
                new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));

        final JmxReporter jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY).build();
        jmxReporter.start();

        bEnableJvm = true;
    }
项目:DuctileDB    文件:Metrics.java   
public static void initialize(MetricRegistry registry) {
if (Metrics.registry != null) {
    throw new IllegalStateException("Metrics were already initialized.");
}
Metrics.registry = registry;
registry.register("memory_usage", new MemoryUsageGaugeSet());
registry.register("garbage_collector", new GarbageCollectorMetricSet());
registry.register("jvm_attributes", new JvmAttributeGaugeSet());

final JmxReporter jmxReporter = JmxReporter.forRegistry(registry).build();
jmxReporter.start();

final Slf4jReporter slf4jReporter = Slf4jReporter.forRegistry(registry)
    .outputTo(LoggerFactory.getLogger("com.puresoltechnologies.famility.server.metrics"))
    .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
slf4jReporter.start(1, TimeUnit.MINUTES);
   }
项目:metrics-zabbix    文件:GetStarted.java   
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);
}
项目:metrics-jvm-nonaccumulating    文件:NonAccumulatingGarbageCollectorMetricSet.java   
/**
 * Constructor sets up the scheduled executor service that runs a background task to
 * calculate non-accumulating gauge readings at periodic intervals.
 *
 * @param garbageCollectorMetricSet a metric set that collects counts and times of garbage collections
 * @param interval the time interval over which to calculate non-accumulating gauge readings
 *                 for all the gauges in {@code garbageCollectorMetricSet}
 * @param scheduledExecutorService scheduled executor service that runs the task to calculate
 *                                 non-accumulating gauge readings at a frequency determined by
 *                                 {@code interval}.
 */
public NonAccumulatingGarbageCollectorMetricSet(
        GarbageCollectorMetricSet garbageCollectorMetricSet, long interval,
        ScheduledExecutorService scheduledExecutorService) {
    this.garbageCollectorMetricSet = garbageCollectorMetricSet;
    this.interval = interval;
    previousValues = new HashMap<String, Long>();
    nonAccumulatingValues = new ConcurrentHashMap<String, Long>();
    if (scheduledExecutorService == null) {
        BasicThreadFactory basicThreadFactory = new BasicThreadFactory.Builder()
                .namingPattern("metrics-gc-stats-update-%d")
                .daemon(false)
                .priority(Thread.NORM_PRIORITY)
                .build();
        this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(basicThreadFactory);
    } else {
        this.scheduledExecutorService = scheduledExecutorService;
    }
    scheduleBackgroundCollectionOfNonAccumulatingValues();
}
项目:metadatamanagement    文件:MetricsConfiguration.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
  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()));

  servletContext.setAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE, metricRegistry);

  FilterRegistration.Dynamic metricsFilter =
      servletContext.addFilter("webappMetricsFilter", new InstrumentedFilter());

  metricsFilter.addMappingForUrlPatterns(
      EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC), true,
      "/*");
  metricsFilter.setAsyncSupported(true);
}
项目:metrics-agent    文件:DropwizardMetricSystem.java   
private void addJVMMetrics(Map<String, Object> configuration) {
    if (!configuration.containsKey("jvm")) {
        return;
    }
    Set<String> jvmMetrics = new HashSet<String>((List<String>)configuration.get("jvm"));
    if (jvmMetrics.contains("gc")) {
        registry.register("gc", new GarbageCollectorMetricSet());
    }

    if (jvmMetrics.contains("threads")) {
        registry.register("threads", new CachedThreadStatesGaugeSet(10, TimeUnit.SECONDS));
    }

    if (jvmMetrics.contains("memory")) {
        registry.register("memory", new MemoryUsageGaugeSet());
    }

    if (jvmMetrics.contains("classloader")) {
        registry.register("memory", new ClassLoadingGaugeSet());
    }
}
项目:tajo    文件:TajoSystemMetrics.java   
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;
}
项目:oneops    文件:OneOpsMetrics.java   
/**
 * Add metrics JVM gauges.
 */
private void addJvmMetrics() {
  if (getB("jvm.gcstats", false)) {
    ooMetricsRegistry.registerAll(new GarbageCollectorMetricSet());
  }
  if (getB("jvm.memory", false)) {
    ooMetricsRegistry.registerAll(new MemoryUsageGaugeSet());
  }
  if (getB("jvm.threadstate", false)) {
    ooMetricsRegistry.registerAll(new ThreadStatesGaugeSet());
  }
  if (getB("jvm.filedescriptor", false)) {
    ooMetricsRegistry.register("openfd.ratio", new FileDescriptorRatioGauge());
  }
}
项目:easyhbase    文件:CollectorMetric.java   
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());
        }
    }
}
项目:curiostack    文件:MonitoringModule.java   
private static void configureJvmMetrics(MetricRegistry registry) {
  MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
  registry.register("jvm.buffer-pool", new BufferPoolMetricSet(mBeanServer));
  registry.register("jvm.class-loading", new ClassLoadingGaugeSet());
  registry.register("jvm.file-descriptor-ratio", new FileDescriptorRatioGauge());
  registry.register("jvm.gc", new GarbageCollectorMetricSet());
  registry.register("jvm.memory", new MemoryUsageGaugeSet());
  registry.register("jvm.threads", new ThreadStatesGaugeSet());
}
项目:feeyo-redisproxy    文件:MetricTest.java   
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() );
    metrics.register("jvm.threads", new ThreadStatesGaugeSet() );
    reporter.start(30, TimeUnit.SECONDS);

    TimeUnit.SECONDS.sleep(500);
}
项目:BCDS    文件:MetricsConfiguration.java   
@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 (propertyResolver.getProperty(PROP_JMX_ENABLED, Boolean.class, false)) {
        log.info("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
}
项目:Microservices-Deployment-Cookbook    文件:MetricSystem.java   
@PostConstruct
    public void init() {
        //      ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(metricRegistry)
        //              .convertRatesTo(TimeUnit.SECONDS)
        //              .convertDurationsTo(TimeUnit.MILLISECONDS)
        //              .build();
        //
        //      consoleReporter.start(10, TimeUnit.SECONDS);

//      Graphite graphite = new Graphite(new InetSocketAddress("192.168.99.100", 2003));
//      GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
//              .prefixedWith("com.packt.microservices.geolocation")
//              .convertRatesTo(TimeUnit.SECONDS)
//              .convertDurationsTo(TimeUnit.MILLISECONDS)
//              .filter(MetricFilter.ALL)
//              .build(graphite);
//      graphiteReporter.start(60, TimeUnit.SECONDS);


        geolocationWriteRequestCount = metricRegistry.counter("geolocationWriteRequestCount");
        metricRegistry.register("geolocationLastWriteTime", new Gauge<Long>() {
            @Override
            public Long getValue() {
                return geolocationLastWriteTime;
            }
        });

        metricRegistry.registerAll(new MetricSet() {
            @Override
            public Map<String, Metric> getMetrics() {

                Map<String, Metric> metrics = new HashMap<>();
                metrics.put("geolocationMemoryUsage", new MemoryUsageGaugeSet());
                metrics.put("geolocationClassLoading", new ClassLoadingGaugeSet());
                metrics.put("geolocationGarbageCollector", new GarbageCollectorMetricSet());
                return metrics;
            }
        });
    }
项目:grakn    文件:GraknCreator.java   
private static TaskManager taskManager(GraknConfig config, EngineGraknTxFactory factory, Pool<Jedis> jedisPool, EngineID engineId, MetricRegistry metricRegistry, PostProcessor postProcessor) {
    metricRegistry.register(name(GraknEngineServer.class, "jedis", "idle"), (Gauge<Integer>) jedisPool::getNumIdle);
    metricRegistry.register(name(GraknEngineServer.class, "jedis", "active"), (Gauge<Integer>) jedisPool::getNumActive);
    metricRegistry.register(name(GraknEngineServer.class, "jedis", "waiters"), (Gauge<Integer>) jedisPool::getNumWaiters);
    metricRegistry.register(name(GraknEngineServer.class, "jedis", "borrow_wait_time_ms", "max"), (Gauge<Long>) jedisPool::getMaxBorrowWaitTimeMillis);
    metricRegistry.register(name(GraknEngineServer.class, "jedis", "borrow_wait_time_ms", "mean"), (Gauge<Long>) jedisPool::getMeanBorrowWaitTimeMillis);

    metricRegistry.register(name(GraknEngineServer.class, "System", "gc"), new GarbageCollectorMetricSet());
    metricRegistry.register(name(GraknEngineServer.class, "System", "threads"), new CachedThreadStatesGaugeSet(15, TimeUnit.SECONDS));
    metricRegistry.register(name(GraknEngineServer.class, "System", "memory"), new MemoryUsageGaugeSet());

    int consumers = config.getProperty(GraknConfigKey.QUEUE_CONSUMERS);
    return new RedisTaskManager(engineId, config, jedisPool, consumers, factory, metricRegistry, postProcessor);
}
项目:riposte    文件:CodahaleMetricsEngine.java   
/**
 * Adds JVM MetricSets to this engine.  By default JVM metrics are not placed in the Registry
 */
public CodahaleMetricsEngine reportJvmMetrics() {
    // add JVM metrics
    if (!jvmMetricsAdded) {
        metricsCollector.registerAll("JVM-gc", new GarbageCollectorMetricSet());
        metricsCollector
            .registerAll("JVM-buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
        metricsCollector.registerAll("JVM-memory", new MemoryUsageGaugeSet());
        metricsCollector.registerAll("JVM-threads", new ThreadStatesGaugeSet());
        jvmMetricsAdded = true;
    }
    return this;
}
项目:Market-monitor    文件:MetricPaasService.java   
public MetricPaasService() throws IOException {
    super();
    metrics.register("Heap", new MemoryUsageGaugeSet());
    metrics.register("GC", new GarbageCollectorMetricSet());
    metrics.register("Thread", new ThreadStatesGaugeSet());
    metrics.register("CPU", new CpuUsageGaugeSet());

    JmxReporter reporter = JmxReporter.forRegistry(metrics).build();
    reporter.start();
}
项目:ehcache3-samples    文件:MetricsConfiguration.java   
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JCACHE_STATISTICS, new JCacheGaugeSet());
    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);
    }
}
项目:haven-platform    文件:MeterConfiguration.java   
@Override
public void configureReporters(MetricRegistry metricRegistry) {
    metricRegistry.addListener(metricsListener);

    metricRegistry.register("jvm.gc", new GarbageCollectorMetricSet());
    metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet());
    metricRegistry.register("jvm.thread-states", new ThreadStatesGaugeSet());
    metricRegistry.register("jvm.fd.usage", new FileDescriptorRatioGauge());


    if(environment.acceptsProfiles(AmqpUtils.PROFILE)) {
        final String applicationId = AppInfo.getApplicationName();
        AmqpUtils.ExchangeFactory exchangeFactory = new AmqpUtils.ExchangeFactory();
        exchangeFactory.setExchangeName(exchange);
        AmqpReporter amqpReporter = AmqpReporter.forRegistry(metricRegistry)
          .connectionFactoryProvider(connectionFactoryProvider)
          .exchangeName(exchange)
          .routingKey(applicationId)
          .exchangeFactory(exchangeFactory)
          .build();
        amqpReporter.start(reportPeriod, TimeUnit.SECONDS);
        LOG.info("AmqpReporter enabled: applicationId: {} reportPeriod: {} seconds, exchange: {}",
                applicationId, reportPeriod, exchange);
    } else {
        //sample configuration for metrics reported
        // https://dropwizard.github.io/metrics/3.1.0/manual/core/#man-core-reporters-console
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
                .outputTo(LoggerFactory.getLogger("com.codeabovelab.dm.metrics"))
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .build();
        reporter.start(reportPeriod, TimeUnit.SECONDS);
    }
}
项目:pravega    文件:StatsProviderImpl.java   
@Synchronized
private void init() {
    // I'm not entirely sure that re-inserting is necessary, but given that
    // at this point we are preserving the registry, it seems safer to remove
    // and re-insert.
    MemoryUsageGaugeSet memoryGaugeNames = new MemoryUsageGaugeSet();
    GarbageCollectorMetricSet gcMetricSet = new GarbageCollectorMetricSet();

    memoryGaugeNames.getMetrics().forEach((key, value) -> metrics.remove(key));
    gcMetricSet.getMetrics().forEach((key, value) -> metrics.remove(key));

    metrics.registerAll(new MemoryUsageGaugeSet());
    metrics.registerAll(new GarbageCollectorMetricSet());
}
项目:graphite-monitor-example    文件:AbstractMonitoringConfiguration.java   
private Builder getGraphiteReporterBuilder(MetricRegistry metricRegistry) {
    metricRegistry.register("gc", new GarbageCollectorMetricSet());
    metricRegistry.register("memory", new MemoryUsageGaugeSet());
    metricRegistry.register("threads", new ThreadStatesGaugeSet());
    metricRegistry.register("os", new OperatingSystemGaugeSet());
    return GraphiteReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).prefixedWith(graphitePrefix);
}
项目:xlator    文件:StatsdRunner.java   
@Override
public void run(String... strings) throws Exception {
    // JVM metrics ala Dropwizard metrics-jvm
    metricRegistry.registerAll(new MemoryUsageGaugeSet());
    metricRegistry.registerAll(new ThreadStatesGaugeSet());
    metricRegistry.registerAll(new GarbageCollectorMetricSet());
    metricRegistry.registerAll(new ClassLoadingGaugeSet());
    // start collecting w/ statsd via ReadyTalk client
    reporter.start(statsdSettings.getPublishingIntervalInMillis(), TimeUnit.MILLISECONDS);
}
项目:drill    文件:DrillMetrics.java   
private static void registerSystemMetrics() {
  REGISTRY.registerAll(new GarbageCollectorMetricSet());
  REGISTRY.registerAll(new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  REGISTRY.registerAll(new MemoryUsageGaugeSet());
  REGISTRY.registerAll(new ThreadStatesGaugeSet());
  register("fd.usage", new FileDescriptorRatioGauge());
}
项目:nexus-public    文件:MetricsServlet.java   
@Inject
public MetricsServlet(final MetricRegistry registry) {
  super(registry);

  // JVM metrics are no longer automatically added in codahale-metrics
  registry.register(name("jvm", "vm"), new JvmAttributeGaugeSet());
  registry.register(name("jvm", "memory"), new MemoryUsageGaugeSet());
  registry.register(name("jvm", "buffers"), new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  registry.register(name("jvm", "fd_usage"), new FileDescriptorRatioGauge());
  registry.register(name("jvm", "thread-states"), new ThreadStatesGaugeSet());
  registry.register(name("jvm", "garbage-collectors"), new GarbageCollectorMetricSet());
}
项目:spike.x    文件:Activator.java   
@Override
protected void startVerticle() {

    m_sharedData = vertx.sharedData().getMap(SHARED_METRICS_KEY);

    // OSHI system information
    SystemInfo systemInfo = new SystemInfo();
    m_oshiMetrics = new OshiMetrics(systemInfo);
    m_oshiMetrics.init();

    // Java OS MXBean information
    m_osMXBeanMetrics = new OSMXBeanMetrics();
    m_osMXBeanMetrics.init();

    // Register metrics
    m_registry = new MetricRegistry();

    logger().debug("Registering JVM garbage collection metric set");
    registerMetrics("jvm.gc", new GarbageCollectorMetricSet(), m_registry);

    logger().debug("Registering JMV buffer metric set");
    registerMetrics("jvm.buffers", new BufferPoolMetricSet(
            ManagementFactory.getPlatformMBeanServer()), m_registry);

    logger().debug("Registering JMV memory usage metric set");
    registerMetrics("jvm.memory", new MemoryUsageGaugeSet(), m_registry);

    logger().debug("Registering JMV thread states metric set");
    registerMetrics("jvm.threads", new ThreadStatesGaugeSet(), m_registry);

    // Aggregate metrics
    registerAggregateMetrics(m_registry);

    // Output system information
    outputSysInfo(systemInfo);
}
项目:lobbycal    文件:MetricsConfiguration.java   
@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();
    }
}
项目:cgif    文件:Global.java   
private void setupMetrics(Configuration configuration) {
  boolean metricsJvm     = configuration.getBoolean("metrics.jvm", false);
  boolean metricsLogback = configuration.getBoolean("metrics.logback", false);
  boolean metricsConsole = configuration.getBoolean("metrics.console", false);

  if(metricsJvm) {
    metricRegistry.registerAll(new GarbageCollectorMetricSet());
    metricRegistry.registerAll(new MemoryUsageGaugeSet());
    metricRegistry.registerAll(new ThreadStatesGaugeSet());
  }

  if (metricsLogback) {
    InstrumentedAppender appender = new InstrumentedAppender(metricRegistry);

    ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger)Logger.underlying();
    appender.setContext(logger.getLoggerContext());
    appender.start();
    logger.addAppender(appender);
  }

  if (metricsConsole) {
    ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(metricRegistry)
      .convertRatesTo(TimeUnit.SECONDS)
      .convertDurationsTo(TimeUnit.MILLISECONDS)
      .build();
    consoleReporter.start(1, TimeUnit.SECONDS);
  }

}
项目:fathom    文件:Metrics.java   
@Override
public void start() {

    String applicationName = settings.getApplicationName();

    // Register optional metrics
    if (settings.getBoolean(Settings.Setting.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");
    }

    // MBeans for VisualVM, JConsole, or JMX
    if (settings.getBoolean(Settings.Setting.metrics_mbeans_enabled, false)) {
        JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).inDomain(applicationName).build();
        reporter.start();
        reporters.add(reporter);

        log.debug("Started metrics MBeans reporter");
    }

    // Add classpath reporters
    ServiceLocator.locateAll(MetricsReporter.class).forEach((reporter) -> {
        if (RequireUtil.allowInstance(settings, reporter)) {
            reporter.start(settings, metricRegistry);
            reporters.add(reporter);
        }
    });
}
项目:carbon-metrics    文件:MetricManager.java   
private void registerJVMMetrics() {
    registerAllJVMMetrics(Level.INFO, "jvm.memory", new MemoryUsageGaugeSet());
    registerAllJVMMetrics(Level.INFO, "jvm.os", new OperatingSystemMetricSet());
    registerAllJVMMetrics(Level.INFO, "jvm.class-loading", new ClassLoadingGaugeSet());
    registerAllJVMMetrics(Level.DEBUG, "jvm.gc", new GarbageCollectorMetricSet());
    registerAllJVMMetrics(Level.DEBUG, "jvm.threads", new ThreadStatesGaugeSet());
    registerAllJVMMetrics(Level.TRACE, "jvm.buffers",
            new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
}
项目:datacollector    文件:MetricsModule.java   
@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;
}
项目:p2p-webtv    文件:MetricsConfiguration.java   
@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 (applicationProperties.getMetrics().getJmx().isEnabled()) {
    log.debug("Initializing Metrics JMX reporting");
    JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
    jmxReporter.start();
  }
}
项目:agate    文件:MetricsConfiguration.java   
@PostConstruct
public void init() {
  log.debug("Registering JVM gauges");
  METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
  METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
  METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
  METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
  METRIC_REGISTRY
      .register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  if(propertyResolver.getProperty(PROP_JMX_ENABLED, Boolean.class, false)) {
    log.info("Initializing Metrics JMX reporting");
    JmxReporter jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY).build();
    jmxReporter.start();
  }
}
项目:modules    文件:MetricRegistryInitializer.java   
/**
 * Registers a default set of metrics for the JVM.
 */
private void registerDefaultMetrics() {
    metricRegistry.register(JVM_GARBAGE_COLLECTOR_METRICS, new GarbageCollectorMetricSet());
    metricRegistry.register(JVM_MEMORY_METRICS, new MemoryUsageGaugeSet());
    metricRegistry.register(JVM_THREAD_METRICS, new ThreadStatesGaugeSet());
    metricRegistry.register(JVM_FILE_DESCRIPTOR_METRICS, new FileDescriptorRatioGauge());
}
项目:incubator-tajo    文件:TajoSystemMetrics.java   
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;
}
项目:tajo-cdh    文件:TajoSystemMetrics.java   
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;
}
项目:incubator-gobblin    文件:JMXReportingService.java   
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());
  }
}
项目:chassis    文件:MetricsConfiguration.java   
/***
    * 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;
}