本文整理汇总了Java中com.spotify.metrics.jvm.GarbageCollectorMetricSet类的典型用法代码示例。如果您正苦于以下问题:Java GarbageCollectorMetricSet类的具体用法?Java GarbageCollectorMetricSet怎么用?Java GarbageCollectorMetricSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GarbageCollectorMetricSet类属于com.spotify.metrics.jvm包,在下文中一共展示了GarbageCollectorMetricSet类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.spotify.metrics.jvm.GarbageCollectorMetricSet; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
registry.register(MetricId.build("jvm-memory"), new MemoryUsageGaugeSet());
registry.register(MetricId.build("jvm-gc"), new GarbageCollectorMetricSet());
registry.register(MetricId.build("jvm-threads"), new ThreadStatesMetricSet());
registry.register(MetricId.build("jvm-cpu"), CpuGaugeSet.create());
registry.register(MetricId.build("jvm-fd-ratio"), new FileDescriptorGaugeSet());
final FastForwardReporter reporter = FastForwardReporter
.forRegistry(registry)
.prefix(APP_PREFIX)
.schedule(TimeUnit.SECONDS, 5)
.build();
reporter.start();
System.out.println("Sending jvm metrics...");
System.in.read();
reporter.stop();
}
示例2: setupStatistics
import com.spotify.metrics.jvm.GarbageCollectorMetricSet; //导入依赖的package包/类
private static Statistics setupStatistics() throws IOException {
final String key = System.getProperty("ffwd.key", "ffwd-java");
final SemanticMetricRegistry registry = new SemanticMetricRegistry();
final SemanticCoreStatistics statistics = new SemanticCoreStatistics(registry);
final MetricId gauges = MetricId.build();
registry.register(gauges, new ThreadStatesMetricSet());
registry.register(gauges, new GarbageCollectorMetricSet());
registry.register(gauges, new MemoryUsageGaugeSet());
final MetricId metric = MetricId.build(key);
final FastForwardReporter ffwd = FastForwardReporter
.forRegistry(registry)
.schedule(TimeUnit.SECONDS, 30)
.prefix(metric)
.build();
ffwd.start();
return new Statistics(ffwd, statistics);
}
示例3: life
import com.spotify.metrics.jvm.GarbageCollectorMetricSet; //导入依赖的package包/类
@Provides
@SemanticStatisticsScope
public LifeCycle life(
AsyncFramework async, SemanticMetricRegistry registry, ServiceInfo info,
LifeCycleRegistry lifeCycleRegistry
) {
final MetricId gauges = MetricId.build();
registry.register(gauges, new ThreadStatesMetricSet());
registry.register(gauges, new GarbageCollectorMetricSet());
registry.register(gauges, new MemoryUsageGaugeSet());
final MetricId metric =
MetricId.build("heroic").tagged("service", "heroic", "heroic_id", info.getId());
final FastForwardReporter reporter;
try {
reporter = FastForwardReporter
.forRegistry(registry)
.schedule(TimeUnit.SECONDS, 30)
.prefix(metric)
.build();
} catch (IOException e) {
throw new RuntimeException("Failed to configure reporter", e);
}
return () -> {
final LifeCycleRegistry scope = lifeCycleRegistry.scoped("ffwd-reporter");
scope.start(() -> async.call(() -> {
reporter.start();
return null;
}));
scope.stop(() -> async.call(() -> {
reporter.stop();
return null;
}));
};
}