本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例8: configure
import com.codahale.metrics.CsvReporter; //导入依赖的package包/类
@Override
protected void configure() {
bind(CsvReporter.class).toProvider(CsvReporterProvider.class);
addConfigBeans();
addInitializer(MetricsCsvReporterService.class);
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}