use of org.wso2.am.analytics.publisher.reporter.MetricReporter in project carbon-apimgt by wso2.
the class AnalyticsDataPublisher method initialize.
public void initialize(AnalyticsCommonConfiguration commonConfig) {
Map<String, String> configs = commonConfig.getConfigurations();
String reporterClass = configs.get("publisher.reporter.class");
try {
MetricReporter metricReporter;
if (reporterClass != null) {
metricReporter = MetricReporterFactory.getInstance().createMetricReporter(reporterClass, configs);
} else {
metricReporter = MetricReporterFactory.getInstance().createMetricReporter(configs);
}
if (!StringUtils.isEmpty(commonConfig.getResponseSchema())) {
this.successMetricReporter = metricReporter.createCounterMetric(Constants.RESPONSE_METRIC_NAME, MetricSchema.valueOf(commonConfig.getResponseSchema()));
} else {
this.successMetricReporter = metricReporter.createCounterMetric(Constants.RESPONSE_METRIC_NAME, MetricSchema.RESPONSE);
}
if (!StringUtils.isEmpty(commonConfig.getFaultSchema())) {
this.faultyMetricReporter = metricReporter.createCounterMetric(Constants.FAULTY_METRIC_NAME, MetricSchema.valueOf(commonConfig.getFaultSchema()));
} else {
this.faultyMetricReporter = metricReporter.createCounterMetric(Constants.FAULTY_METRIC_NAME, MetricSchema.ERROR);
}
// Illegal Argument is possible as the enum conversion could fail
} catch (MetricCreationException | IllegalArgumentException e) {
log.error("Error initializing event publisher.", e);
}
}
Aggregations