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


Java CsvReporter.start方法代码示例

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


在下文中一共展示了CsvReporter.start方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例4: 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

示例5: 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

示例6: registerMetricsReporters

import com.codahale.metrics.CsvReporter; //导入方法依赖的package包/类
private void registerMetricsReporters( Application application, MetricRegistry metrics )
{
    Config config = application.config().atKey( "metrics" );

    reporters = new ArrayList<>();

    // JMX Reporter
    if( config.bool( "reports.jmx.enabled" ) )
    {
        JmxReporter jmx = JmxReporter.forRegistry( metrics )
            .convertRatesTo( TimeUnit.SECONDS )
            .convertDurationsTo( TimeUnit.MILLISECONDS )
            .build();
        jmx.start();
        reporters.add( jmx );
    }

    // Console Reporter
    if( config.bool( "reports.console.enabled" ) )
    {
        ConsoleReporter console = ConsoleReporter.forRegistry( metrics )
            .convertRatesTo( TimeUnit.SECONDS )
            .convertDurationsTo( TimeUnit.MILLISECONDS )
            .build();
        console.start( config.seconds( "reports.console.periodicity" ), TimeUnit.SECONDS );
        reporters.add( console );
    }

    // SLF4J Reporter
    if( config.bool( "reports.slf4j.enabled" ) )
    {
        final Slf4jReporter slf4j = Slf4jReporter.forRegistry( metrics )
            .outputTo( LoggerFactory.getLogger( config.string( "reports.slf4j.logger" ) ) )
            .withLoggingLevel(
                Slf4jReporter.LoggingLevel.valueOf( config.string( "reports.slf4j.level" ).toUpperCase( US ) )
            )
            .markWith( MarkerFactory.getMarker( "metrics" ) )
            .convertRatesTo( TimeUnit.SECONDS )
            .convertDurationsTo( TimeUnit.MILLISECONDS )
            .build();
        slf4j.start( config.seconds( "reports.slf4j.periodicity" ), TimeUnit.SECONDS );
        reporters.add( slf4j );
    }

    // CSV Reporter
    if( config.bool( "reports.csv.enabled" ) )
    {
        File csvReportDir = new File( config.string( "reports.csv.directory" ) );
        csvReportDir.mkdirs();
        final CsvReporter csv = CsvReporter.forRegistry( metrics )
            .formatFor( Locale.forLanguageTag( config.string( "reports.csv.locale" ) ) )
            .convertRatesTo( TimeUnit.SECONDS )
            .convertDurationsTo( TimeUnit.MILLISECONDS )
            .build( csvReportDir );
        csv.start( config.seconds( "reports.csv.periodicity" ), TimeUnit.SECONDS );
        reporters.add( csv );
    }
}
 
开发者ID:werval,项目名称:werval,代码行数:59,代码来源:MetricsPlugin.java

示例7: StartReportingMetricsToCSV

import com.codahale.metrics.CsvReporter; //导入方法依赖的package包/类
public StartReportingMetricsToCSV(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) {
  super(builder, config, parent, child, context);      
  
  MetricFilter filter = PatternMetricFilter.parse(getConfigs(), config);
  TimeUnit defaultDurationUnit = getConfigs().getTimeUnit(config, "defaultDurationUnit", TimeUnit.MILLISECONDS);
  TimeUnit defaultRateUnit = getConfigs().getTimeUnit(config, "defaultRateUnit", TimeUnit.SECONDS); 
  long frequency = getConfigs().getNanoseconds(config, "frequency", 10 * 1000L * 1000 * 1000); // 10 seconds
  if (LOG.isTraceEnabled()) {
    LOG.trace("availableLocales: {}", Joiner.on("\n").join(Locale.getAvailableLocales()));
  }
  Locale locale = getConfigs().getLocale(config, "locale", Locale.getDefault());
  this.outputDir = new File(getConfigs().getString(config, "outputDir"));
  validateArguments();
  
  MetricRegistry registry = context.getMetricRegistry();
  synchronized (REGISTRIES) {
    Map<File, CsvReporter> reporters = REGISTRIES.get(registry);
    if (reporters == null) {
      reporters = new HashMap();
      REGISTRIES.put(registry, reporters);
    }
    CsvReporter reporter = reporters.get(outputDir);
    if (reporter == null) {
      Builder reporterBuilder = CsvReporter.forRegistry(registry)
          .filter(filter)
          .convertDurationsTo(defaultDurationUnit)
          .convertRatesTo(defaultRateUnit)
          .formatFor(locale);
          
      reporter = reporterBuilder.build(outputDir);
      outputDir.mkdirs();
      if (!outputDir.isDirectory()) {
        throw new MorphlineCompilationException("Directory not found: " + outputDir, config);
      }
      if (!outputDir.canWrite()) {
        throw new MorphlineCompilationException("Directory not writeable: " + outputDir, config);
      }
      reporter.start(frequency, TimeUnit.NANOSECONDS);
      reporters.put(outputDir, reporter);
    }
  }
}
 
开发者ID:cloudera,项目名称:cdk,代码行数:43,代码来源:StartReportingMetricsToCSVBuilder.java


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