Search in sources :

Example 1 with CustomizableMetricsReporter

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());
}
Also used : CustomizableMetricsReporter(org.apache.hudi.metrics.custom.CustomizableMetricsReporter) CustomizableMetricsReporter(org.apache.hudi.metrics.custom.CustomizableMetricsReporter) TypedProperties(org.apache.hudi.common.config.TypedProperties) Test(org.junit.jupiter.api.Test)

Example 2 with CustomizableMetricsReporter

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;
}
Also used : HoodieException(org.apache.hudi.exception.HoodieException) PrometheusReporter(org.apache.hudi.metrics.prometheus.PrometheusReporter) CloudWatchMetricsReporter(org.apache.hudi.metrics.cloudwatch.CloudWatchMetricsReporter) CloudWatchMetricsReporter(org.apache.hudi.metrics.cloudwatch.CloudWatchMetricsReporter) DatadogMetricsReporter(org.apache.hudi.metrics.datadog.DatadogMetricsReporter) CustomizableMetricsReporter(org.apache.hudi.metrics.custom.CustomizableMetricsReporter) PushGatewayMetricsReporter(org.apache.hudi.metrics.prometheus.PushGatewayMetricsReporter) DatadogMetricsReporter(org.apache.hudi.metrics.datadog.DatadogMetricsReporter) CustomizableMetricsReporter(org.apache.hudi.metrics.custom.CustomizableMetricsReporter) PushGatewayMetricsReporter(org.apache.hudi.metrics.prometheus.PushGatewayMetricsReporter)

Aggregations

CustomizableMetricsReporter (org.apache.hudi.metrics.custom.CustomizableMetricsReporter)2 TypedProperties (org.apache.hudi.common.config.TypedProperties)1 HoodieException (org.apache.hudi.exception.HoodieException)1 CloudWatchMetricsReporter (org.apache.hudi.metrics.cloudwatch.CloudWatchMetricsReporter)1 DatadogMetricsReporter (org.apache.hudi.metrics.datadog.DatadogMetricsReporter)1 PrometheusReporter (org.apache.hudi.metrics.prometheus.PrometheusReporter)1 PushGatewayMetricsReporter (org.apache.hudi.metrics.prometheus.PushGatewayMetricsReporter)1 Test (org.junit.jupiter.api.Test)1