use of org.apache.hudi.metrics.custom.CustomizableMetricsReporter in project hudi by apache.
the class TestMetricsReporterFactory method metricsReporterFactoryShouldReturnUserDefinedReporter.
@Test
public void metricsReporterFactoryShouldReturnUserDefinedReporter() {
when(config.getMetricReporterClassName()).thenReturn(DummyMetricsReporter.class.getName());
TypedProperties props = new TypedProperties();
props.setProperty("testKey", "testValue");
when(config.getProps()).thenReturn(props);
MetricsReporter reporter = MetricsReporterFactory.createReporter(config, registry);
assertTrue(reporter instanceof CustomizableMetricsReporter);
assertEquals(props, ((DummyMetricsReporter) reporter).getProps());
assertEquals(registry, ((DummyMetricsReporter) reporter).getRegistry());
}
use of org.apache.hudi.metrics.custom.CustomizableMetricsReporter in project hudi by apache.
the class MetricsReporterFactory method createReporter.
public static MetricsReporter createReporter(HoodieWriteConfig config, MetricRegistry registry) {
String reporterClassName = config.getMetricReporterClassName();
if (!StringUtils.isNullOrEmpty(reporterClassName)) {
Object instance = ReflectionUtils.loadClass(reporterClassName, new Class<?>[] { Properties.class, MetricRegistry.class }, config.getProps(), registry);
if (!(instance instanceof CustomizableMetricsReporter)) {
throw new HoodieException(config.getMetricReporterClassName() + " is not a subclass of CustomizableMetricsReporter");
}
return (MetricsReporter) instance;
}
MetricsReporterType type = config.getMetricsReporterType();
MetricsReporter reporter = null;
switch(type) {
case GRAPHITE:
reporter = new MetricsGraphiteReporter(config, registry);
break;
case INMEMORY:
reporter = new InMemoryMetricsReporter();
break;
case JMX:
reporter = new JmxMetricsReporter(config, registry);
break;
case DATADOG:
reporter = new DatadogMetricsReporter(config, registry);
break;
case PROMETHEUS_PUSHGATEWAY:
reporter = new PushGatewayMetricsReporter(config, registry);
break;
case PROMETHEUS:
reporter = new PrometheusReporter(config, registry);
break;
case CONSOLE:
reporter = new ConsoleMetricsReporter(registry);
break;
case CLOUDWATCH:
reporter = new CloudWatchMetricsReporter(config, registry);
break;
default:
LOG.error("Reporter type[" + type + "] is not supported.");
break;
}
return reporter;
}
Aggregations