/** * 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); }
/** * 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); }
/** * 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 createSlf4jReporter( MetricRegistry metricRegistry, Map<String, Object> config) { String loggerName = (String) config.getOrDefault("logger", "metrics:reporter"); return Slf4jReporter.forRegistry(metricRegistry) .convertRatesTo(getRatesUnit(config)) .convertDurationsTo(getDurationUnit(config)) .outputTo(LoggerFactory.getLogger(loggerName)) .build(); }
/** * 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 createSlf4jReporter( MetricRegistry metricRegistry, Map<String, Object> config) { String loggerName = (String) config.getOrDefault("logger", "metrics:reporter"); return Slf4jReporter.forRegistry(metricRegistry) .convertRatesTo(getRatesUnit(config)) .convertDurationsTo(getDurationUnit(config)) .outputTo(LoggerFactory.getLogger(loggerName)) .build(); }
/** * Create a new console reporter. * * @param metricRegistry the registry to report on * @param config the configuration map (see {@link MetricsFactory}) * @return the reporter instance */ public static ScheduledReporter createConsoleReporter( MetricRegistry metricRegistry, Map<String, Object> config) { return ConsoleReporter.forRegistry(metricRegistry) .convertRatesTo(getRatesUnit(config)) .convertDurationsTo(getDurationUnit(config)) .build(); }
/** * Create a new console reporter. * * @param metricRegistry the registry to report on * @param config the configuration map (see {@link MetricsFactory}) * @return the reporter instance */ public static ScheduledReporter createConsoleReporter( MetricRegistry metricRegistry, Map<String, Object> config) { return ConsoleReporter.forRegistry(metricRegistry) .convertRatesTo(getRatesUnit(config)) .convertDurationsTo(getDurationUnit(config)) .build(); }
/** * Create a new ElasticSearch reporter. * * @param metricRegistry the registry to report on * @param config the configuration map (see {@link MetricsFactory}) * @return the reporter instance */ public static ScheduledReporter createElasticSearchReporter( MetricRegistry metricRegistry, Map<String, Object> config) throws BaleenException { try { String server = (String) config.getOrDefault("server", "localhost:9200"); String index = (String) config.getOrDefault("index", "metrics"); int timeout = (int) config.getOrDefault("timeout", 1000); int bulkSize = (int) config.getOrDefault("bulkSize", 2500); return ElasticsearchReporter.forRegistry(metricRegistry) .convertRatesTo(getRatesUnit(config)) .convertDurationsTo(getDurationUnit(config)) .bulkSize(bulkSize) .hosts(server) .index(index) .timeout(timeout) .build(); } catch (IOException e) { throw new BaleenException("Unable to create ElasticSearch reporter", e); } }
/** * Create a new ElasticSearch reporter. * * @param metricRegistry the registry to report on * @param config the configuration map (see {@link MetricsFactory}) * @return the reporter instance */ public static ScheduledReporter createElasticSearchReporter( MetricRegistry metricRegistry, Map<String, Object> config) throws BaleenException { try { String server = (String) config.getOrDefault("server", "localhost:9200"); String index = (String) config.getOrDefault("index", "metrics"); int timeout = (int) config.getOrDefault("timeout", 1000); int bulkSize = (int) config.getOrDefault("bulkSize", 2500); return ElasticsearchReporter.forRegistry(metricRegistry) .convertRatesTo(getRatesUnit(config)) .convertDurationsTo(getDurationUnit(config)) .bulkSize(bulkSize) .hosts(server) .index(index) .timeout(timeout) .build(); } catch (IOException e) { throw new BaleenException("Unable to create ElasticSearch reporter", e); } }