當前位置: 首頁>>代碼示例>>Java>>正文


Java GarbageCollectorMetricSet類代碼示例

本文整理匯總了Java中com.codahale.metrics.jvm.GarbageCollectorMetricSet的典型用法代碼示例。如果您正苦於以下問題:Java GarbageCollectorMetricSet類的具體用法?Java GarbageCollectorMetricSet怎麽用?Java GarbageCollectorMetricSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GarbageCollectorMetricSet類屬於com.codahale.metrics.jvm包,在下文中一共展示了GarbageCollectorMetricSet類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMetricsHandler

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
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;
}
 
開發者ID:flipkart-incubator,項目名稱:Poseidon,代碼行數:19,代碼來源:Poseidon.java

示例2: init

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
@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());
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:26,代碼來源:MetricsHelper.java

示例3: JvmMetricSet

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
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);
  }
}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:17,代碼來源:JvmMetricSet.java

示例4: build

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
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);
        }
 
開發者ID:azagniotov,項目名稱:codahale-aggregated-metrics-cloudwatch-reporter,代碼行數:19,代碼來源:CloudWatchReporter.java

示例5: enableJvm

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
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;
	}
 
開發者ID:e-baloo,項目名稱:it-keeps,代碼行數:18,代碼來源:MetricsFactory.java

示例6: initialize

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
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);
   }
 
開發者ID:PureSolTechnologies,項目名稱:DuctileDB,代碼行數:18,代碼來源:Metrics.java

示例7: main

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
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);
}
 
開發者ID:hengyunabc,項目名稱:metrics-zabbix,代碼行數:17,代碼來源:GetStarted.java

示例8: NonAccumulatingGarbageCollectorMetricSet

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:gburton1,項目名稱:metrics-jvm-nonaccumulating,代碼行數:31,代碼來源:NonAccumulatingGarbageCollectorMetricSet.java

示例9: onStartup

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
@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);
}
 
開發者ID:dzhw,項目名稱:metadatamanagement,代碼行數:20,代碼來源:MetricsConfiguration.java

示例10: addJVMMetrics

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
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());
    }
}
 
開發者ID:willfleury,項目名稱:metrics-agent,代碼行數:22,代碼來源:DropwizardMetricSystem.java

示例11: start

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
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;
}
 
開發者ID:apache,項目名稱:tajo,代碼行數:19,代碼來源:TajoSystemMetrics.java

示例12: addJvmMetrics

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
/**
 * 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());
  }
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:18,代碼來源:OneOpsMetrics.java

示例13: initRegistry

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
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());
        }
    }
}
 
開發者ID:fchenxi,項目名稱:easyhbase,代碼行數:15,代碼來源:CollectorMetric.java

示例14: configureJvmMetrics

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
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());
}
 
開發者ID:curioswitch,項目名稱:curiostack,代碼行數:10,代碼來源:MonitoringModule.java

示例15: main

import com.codahale.metrics.jvm.GarbageCollectorMetricSet; //導入依賴的package包/類
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);
}
 
開發者ID:variflight,項目名稱:feeyo-redisproxy,代碼行數:13,代碼來源:MetricTest.java


注:本文中的com.codahale.metrics.jvm.GarbageCollectorMetricSet類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。