本文整理汇总了Java中com.codahale.metrics.ConsoleReporter.start方法的典型用法代码示例。如果您正苦于以下问题:Java ConsoleReporter.start方法的具体用法?Java ConsoleReporter.start怎么用?Java ConsoleReporter.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.codahale.metrics.ConsoleReporter
的用法示例。
在下文中一共展示了ConsoleReporter.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTimerForPdxTypeMetrics
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的package包/类
public static void addTimerForPdxTypeMetrics(final ClientCache clientCache) {
Region temp = clientCache.getRegion("PdxTypes");
if (temp == null) {
temp = clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY).create("PdxTypes");
}
final Region pdxRegions = temp;
metricRegistry.register(MetricRegistry.name("PdxTypes", "count"),
(Gauge<Integer>) () -> pdxRegions.keySetOnServer().size());
ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
reporter.start(1, TimeUnit.MINUTES);
}
示例2: main
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
MemoryConsumer consumer = new MemoryConsumer();
GcMonitor gcMonitor = GcMonitor.builder()
.addRollingWindow("15min", Duration.ofMinutes(15))
.build();
gcMonitor.start();
MetricRegistry registry = new MetricRegistry();
registry.registerAll(DropwizardAdapter.toMetricSet("jvm-gc-monitor", gcMonitor));
ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(registry).build();
consoleReporter.start(10, TimeUnit.SECONDS);
try {
while (true) {
consumer.consume(ThreadLocalRandom.current().nextInt(10) + 1, 1);
consumer.consume(ThreadLocalRandom.current().nextInt(20) + 100, 1);
TimeUnit.SECONDS.sleep(5);
}
} finally {
consumer.close();
gcMonitor.stop();
}
}
示例3: main
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的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);
}
示例4: run
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的package包/类
@Override
public void run(ExampleConfiguration configuration, Environment environment) throws Exception {
if(configuration.metricsEnabled()) {
final Graphite graphite = new Graphite(new InetSocketAddress("graphite.example.com", 2003));
final GraphiteReporter reporter = GraphiteReporter.forRegistry(environment.metrics())
.prefixedWith("prefix")
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.filter(MetricFilter.ALL)
.build(graphite);
reporter.start(5, TimeUnit.SECONDS);
final ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(environment.metrics()).build();
consoleReporter.start(5, TimeUnit.SECONDS);
}
final ExampleResource exampleResource = new ExampleResource(environment.metrics());
environment.jersey().register(exampleResource);
}
示例5: testRegister
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的package包/类
@Test
@Ignore("ad-hoc")
public void testRegister() throws Exception {
// reporterAgent.allowedBeans= new ImmutableMap.Builder<String, String>().put("java.lang:type=Memory.HeapMemoryUsage","sssswww").build();
String file = this.getClass().getResource("/test2.json").getFile();
reporterAgent.readConfig(file);
reporterAgent.initLogger();
reporterAgent.registerPlatformBeans();
reporterAgent.addBeanNotificationListener();
ConsoleReporter reporter= ConsoleReporter.forRegistry(reporterAgent.metricRegistry)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
reporter.start(1, TimeUnit.SECONDS);
while(true) {
// eat some memory
String s = "";
for (int i = 0; i < 100000; i++) {
s+="asdasdasd";
}
}
}
示例6: initReporting
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的package包/类
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;
}
}
}
示例7: start
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的package包/类
@Override
public List<AutoCloseable> start(Params params) {
SimpleConfiguration config =
new FluoConfiguration(params.getConfiguration()).getReporterConfiguration("console");
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());
PrintStream out = System.out;
if (config.getString("target", "stdout").equals("stderr")) {
out = System.err;
}
ConsoleReporter reporter = ConsoleReporter.forRegistry(params.getMetricRegistry())
.convertDurationsTo(durationUnit).convertRatesTo(rateUnit).outputTo(out).build();
reporter.start(config.getInt("frequency", 60), TimeUnit.SECONDS);
log.info("Reporting metrics to console");
return Collections.singletonList((AutoCloseable) reporter);
}
示例8: startReport
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的package包/类
protected void startReport() {
ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
reporter.start(1, TimeUnit.SECONDS);
}
示例9: report
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的package包/类
@Override
public void report(MetricRegistry metricRegistry) {
final ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
reporter.start(1, TimeUnit.MINUTES);
}
示例10: main
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的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);
}
示例11: setUp
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的package包/类
@Before
public void setUp() {
ConsoleReporter reporter = ConsoleReporter.forRegistry(METRIC_REGISTRY)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
reporter.start(1, TimeUnit.SECONDS);
}
示例12: startReport
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的package包/类
static void startReport() {
ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
reporter.start(1, TimeUnit.SECONDS);
}
示例13: consoleMetricReporter
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的package包/类
@Bean
@ConditionalOnProperty(prefix = "hono.metric.reporter.console", name = "active", havingValue = "true")
public ConsoleReporter consoleMetricReporter(
@Value("${hono.metric.reporter.console.period:5000}") final Long period) {
LOG.info("metrics - console reporter activated");
final ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(metricRegistry)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.filter(MetricFilter.ALL)
.build();
consoleReporter.start(period, TimeUnit.MILLISECONDS);
return consoleReporter;
}
示例14: consoleReporter
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的package包/类
public ConsoleReporter consoleReporter( MetricRegistry registry ) {
ConsoleReporter reporter = ConsoleReporter.forRegistry(registry)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
reporter.start(10, TimeUnit.SECONDS);
return reporter;
}
示例15: main
import com.codahale.metrics.ConsoleReporter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
final MetricRegistry metrics = new MetricRegistry();
final HadoopMetrics2Reporter metrics2Reporter = HadoopMetrics2Reporter.forRegistry(metrics)
.build(DefaultMetricsSystem.initialize("StandaloneTest"), // The application-level name
"Test", // Component name
"Test", // Component description
"Test"); // Name for each metric record
final ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(metrics).build();
MetricsSystem metrics2 = DefaultMetricsSystem.instance();
// Writes to stdout without a filename configuration
// Will be invoked every 10seconds by default
FileSink sink = new FileSink();
metrics2.register("filesink", "filesink", sink);
sink.init(new SubsetConfiguration(null, null) {
public String getString(String key) {
if (key.equals("filename")) {
return null;
}
return super.getString(key);
}
});
// How often should the dropwizard reporter be invoked
metrics2Reporter.start(500, TimeUnit.MILLISECONDS);
// How often will the dropwziard metrics be logged to the console
consoleReporter.start(2, TimeUnit.SECONDS);
generateMetrics(metrics, 5000, 25, TimeUnit.MILLISECONDS, metrics2Reporter, 10);
}