当前位置: 首页>>代码示例>>Java>>正文


Java CsvReporter类代码示例

本文整理汇总了Java中com.codahale.metrics.CsvReporter的典型用法代码示例。如果您正苦于以下问题:Java CsvReporter类的具体用法?Java CsvReporter怎么用?Java CsvReporter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CsvReporter类属于com.codahale.metrics包,在下文中一共展示了CsvReporter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: report

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
@Override
public void report(MetricRegistry metricRegistry) {

    JbootMetricsCVRReporterConfig cvrReporterConfig = Jboot.config(JbootMetricsCVRReporterConfig.class);

    if (StringUtils.isBlank(cvrReporterConfig.getPath())) {
        throw new NullPointerException("csv reporter path must not be null, please config jboot.metrics.reporter.cvr.path in you properties.");
    }

    final CsvReporter reporter = CsvReporter.forRegistry(metricRegistry)
            .formatFor(Locale.US)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build(new File(cvrReporterConfig.getPath()));

    reporter.start(1, TimeUnit.SECONDS);
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:18,代码来源:CSVReporter.java

示例2: initMetricsCSVOutput

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
private void initMetricsCSVOutput() {
  int timeIntervalMS = conf.getInt(
          SLSConfiguration.METRICS_RECORD_INTERVAL_MS,
          SLSConfiguration.METRICS_RECORD_INTERVAL_MS_DEFAULT);
  File dir = new File(metricsOutputDir + "/metrics");
  if(! dir.exists()
          && ! dir.mkdirs()) {
    LOG.error("Cannot create directory " + dir.getAbsoluteFile());
  }
  final CsvReporter reporter = CsvReporter.forRegistry(metrics)
          .formatFor(Locale.US)
          .convertRatesTo(TimeUnit.SECONDS)
          .convertDurationsTo(TimeUnit.MILLISECONDS)
          .build(new File(metricsOutputDir + "/metrics"));
  reporter.start(timeIntervalMS, TimeUnit.MILLISECONDS);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:ResourceSchedulerWrapper.java

示例3: createAndGetConfiguredCSVReporter

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
private ScheduledReporter createAndGetConfiguredCSVReporter(String prefix, String csvDir) throws IOException {
    // NOTE:
    // 1) metrics output files are exclusive to a given process
    // 2) the output directory must exist
    // 3) if output files already exist they are not overwritten and there is no metrics output
    File outputDir;
    if (Strings.isNullOrEmpty(prefix)) {
        outputDir = new File(csvDir, prefix);
    } else {
        outputDir = new File(csvDir);
    }
    FileUtils.forceMkdir(outputDir);
    LOG.info("Configuring stats with csv output to directory [{}]", outputDir.getAbsolutePath());
    return CsvReporter.forRegistry(metrics)
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build(outputDir);
}
 
开发者ID:apache,项目名称:incubator-omid,代码行数:19,代码来源:CodahaleMetricsProvider.java

示例4: attachCSVReporter

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
/**
 * Attaches a {@link CsvReporter} to provided {@link MetricsHandler}
 * @param metricsHandler
 * @param id
 * @param period
 * @param outputFile
 * @throws RequiredInputMissingException
 */
private static void attachCSVReporter(final MetricsHandler metricsHandler, final String id, final int period, final String outputFile) throws RequiredInputMissingException {

	//////////////////////////////////////////////////////////////////////////
	// validate input
	if(StringUtils.isBlank(id))
		throw new RequiredInputMissingException("Missing required metric reporter id");
	if(metricsHandler == null)
		throw new RequiredInputMissingException("Missing required metrics handler");
	if(StringUtils.isBlank(outputFile))
		throw new RequiredInputMissingException("Missing required output file for CSV metrics writer");
	File oFile = new File(outputFile);
	if(oFile.isDirectory())
		throw new RequiredInputMissingException("Output file points to directory");
	//////////////////////////////////////////////////////////////////////////

	final CsvReporter reporter = CsvReporter.forRegistry(metricsHandler.getRegistry())
			.formatFor(Locale.US).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS)
               .build(oFile);
	reporter.start((period > 0 ? period : 1), TimeUnit.SECONDS);
	metricsHandler.addScheduledReporter(id, reporter);
}
 
开发者ID:ottogroup,项目名称:SPQR,代码行数:30,代码来源:MetricsReporterFactory.java

示例5: enableCSVReporter

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
public static void enableCSVReporter() {
  LOGGER.info("Init CSV Reporter");

  String tempDir = System.getProperty("java.io.tmpdir");
  File tempFile = new File(tempDir);
  File outputDir = new File(tempFile, "/perf-agent/");
  if (!outputDir.exists()) {
    outputDir.mkdirs();
  }

  final CsvReporter reporter = CsvReporter.forRegistry(METRIC_REGISTRY).formatFor(Locale.US).convertRatesTo(TimeUnit.SECONDS)
    .convertDurationsTo(TimeUnit.MILLISECONDS).build(outputDir);
  reporter.start(1, TimeUnit.MINUTES);

  LOGGER.info("CSV File generated on:" + outputDir.getAbsolutePath());
}
 
开发者ID:agigleux,项目名称:perf-agent,代码行数:17,代码来源:MetricReporter.java

示例6: doNotify

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
@Override
protected void doNotify(Record notification) {
  for (Object event : Notifications.getLifecycleEvents(notification)) {
    if (event == Notifications.LifecycleEvent.SHUTDOWN) {
      synchronized (REGISTRIES) {
        Map<File, CsvReporter> reporters = REGISTRIES.get(getContext().getMetricRegistry());
        if (reporters != null) {
          CsvReporter reporter = reporters.remove(outputDir);
          if (reporter != null) {
            reporter.stop();
          }
        }
      }
    }
  }
  super.doNotify(notification);
}
 
开发者ID:cloudera,项目名称:cdk,代码行数:18,代码来源:StartReportingMetricsToCSVBuilder.java

示例7: start

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
@Override
public List<AutoCloseable> start(Params params) {
  SimpleConfiguration config =
      new FluoConfiguration(params.getConfiguration()).getReporterConfiguration("csv");

  String dir = config.getString("dir", "");
  if (!config.getBoolean("enable", false) || dir.isEmpty()) {
    return Collections.emptyList();
  }

  TimeUnit rateUnit = TimeUnit.valueOf(config.getString("rateUnit", "seconds").toUpperCase());
  TimeUnit durationUnit =
      TimeUnit.valueOf(config.getString("durationUnit", "milliseconds").toUpperCase());

  CsvReporter reporter = CsvReporter.forRegistry(params.getMetricRegistry())
      .convertDurationsTo(durationUnit).convertRatesTo(rateUnit).build(new File(dir));
  reporter.start(config.getInt("frequency", 60), TimeUnit.SECONDS);

  log.info("Reporting metrics as csv to directory {}", dir);

  return Collections.singletonList((AutoCloseable) reporter);
}
 
开发者ID:apache,项目名称:fluo,代码行数:23,代码来源:CsvReporterStarter.java

示例8: configure

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
@Override
protected void configure() {
    bind(CsvReporter.class).toProvider(CsvReporterProvider.class);

    addConfigBeans();
    addInitializer(MetricsCsvReporterService.class);
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-metrics-reporter,代码行数:8,代码来源:MetricsCsvReporterModule.java

示例9: get

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
@Override
public CsvReporter get() {
    return CsvReporter.forRegistry(metricRegistry)
            .formatFor(configuration.getLocale())
            .convertDurationsTo(configuration.getUnitDurations())
            .convertRatesTo(configuration.getUnitRates())
            .filter(new RegexMetricFilter(configuration.getIncludeMetrics()))
            .build(configuration.getDirectory());
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-metrics-reporter,代码行数:10,代码来源:CsvReporterProvider.java

示例10: withCsvReporter

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
public CodahaleMetricsAssembler withCsvReporter( File outDirectory, long period, TimeUnit timeunit )
{
    declaration.reportersFactories.add( metricRegistry -> {
        CsvReporter reporter = CsvReporter.forRegistry( metricRegistry ).build( outDirectory );
        reporter.start( period, timeunit );
        return reporter;
    });
    return this;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:10,代码来源:CodahaleMetricsAssembler.java

示例11: createCsvReporter

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
/**
 * Create a new CSV reporter.
 *
 * @param metricRegistry
 *            the registry to report on
 * @param config
 *            the configuration map (see {@link MetricsFactory})
 * @return the reporter instance
 */
public static ScheduledReporter createCsvReporter(MetricRegistry metricRegistry, Map<String, Object> config)
	throws BaleenException{
	String directoryPath = (String) config.getOrDefault("directory", "metrics");
	File directory = new File(directoryPath);

	if (!directory.exists() && !directory.mkdirs()){
		throw new BaleenException("Unable to create directories for CSV Reporter");
	}

	return CsvReporter.forRegistry(metricRegistry).convertRatesTo(getRatesUnit(config))
			.convertDurationsTo(getDurationUnit(config)).build(directory);
}
 
开发者ID:dstl,项目名称:baleen,代码行数:22,代码来源:ReporterUtils.java

示例12: start

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
public static void start() {
    File metricsOut = new File("target/metrics");
    if(!metricsOut.exists()) {
        metricsOut.mkdirs();
    }
    CSV_REPORTER = CsvReporter.forRegistry(REGISTRY).build(metricsOut);
    CSV_REPORTER.start(10, TimeUnit.SECONDS);
}
 
开发者ID:bedatadriven,项目名称:appengine-hibernate,代码行数:9,代码来源:Metrics.java

示例13: ReportersManager

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
@Inject
ReportersManager(MetricRegistry codaRegistry) {
  jmx = JmxReporter.forRegistry(codaRegistry).build();
  jmx.start();

  File dir = new File("./build/metrics");
  dir.mkdirs();
  csv = CsvReporter.forRegistry(codaRegistry).build(dir);
  csv.start(5, TimeUnit.SECONDS);
}
 
开发者ID:brharrington,项目名称:spectator-examples,代码行数:11,代码来源:Main.java

示例14: buildReporter

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
/**
 * @param metricRegistry
 * @return
 */
public CsvReporter buildReporter(final MetricRegistry metricRegistry, final Exchange creatingExchange, final MetricGroup metricGroup) {
	CsvReporterDefinition definitionWithDefaults = getReporterDefinitionWithDefaults();

	final String filterValue = evaluateValue(definitionWithDefaults.getFilter(), definitionWithDefaults.getRuntimeFilter(), definitionWithDefaults.getRuntimeSimpleFilter(), creatingExchange);
	final String directoryValue = evaluateValue(definitionWithDefaults.getDirectory(), definitionWithDefaults.getRuntimeDirectory(), definitionWithDefaults.getRuntimeSimpleDirectory(), creatingExchange);

	// @formatter:off
	CsvReporter csvReporter = CsvReporter
			.forRegistry(metricRegistry)
			.convertDurationsTo(definitionWithDefaults.getDurationUnit())
			.convertRatesTo(definitionWithDefaults.getRateUnit())
			.filter(new MetricFilter(){
				@Override
				public boolean matches(final String name, final Metric metric) {
					if(!metricGroup.contains(metric)){
						return false;
					}
					if(name==null || filterValue==null){
						return true;
					}
					boolean result = name.matches(filterValue);
					return result;
				}
			})
			.build(new File(directoryValue));
	// @formatter:on
	return csvReporter;
}
 
开发者ID:InitiumIo,项目名称:camel-metrics,代码行数:33,代码来源:CsvReporterDefinition.java

示例15: displayMetrics

import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
public static void displayMetrics() {
    ConsoleReporter.forRegistry(registry)
            .build()
            .report();
    CsvReporter.forRegistry(registry)
            .build(new File("target/"))
            .report();
}
 
开发者ID:cardillo,项目名称:joinery,代码行数:9,代码来源:Metrics.java


注:本文中的com.codahale.metrics.CsvReporter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。