Search in sources :

Example 6 with DataPrepperConfiguration

use of com.amazon.dataprepper.parser.model.DataPrepperConfiguration in project data-prepper by opensearch-project.

the class MetricsConfigTest method testGivenEmptyConfigThenMeterRegistryCreated.

@Test
public void testGivenEmptyConfigThenMeterRegistryCreated() {
    final DataPrepperConfiguration dataPrepperConfiguration = mock(DataPrepperConfiguration.class);
    when(dataPrepperConfiguration.getMetricRegistryTypes()).thenReturn(Collections.emptyList());
    final MeterRegistry meterRegistry = metricsConfig.prometheusMeterRegistry(dataPrepperConfiguration);
    assertThat(meterRegistry, is(nullValue()));
}
Also used : DataPrepperConfiguration(com.amazon.dataprepper.parser.model.DataPrepperConfiguration) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) EMFLoggingMeterRegistry(com.amazon.dataprepper.meter.EMFLoggingMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) CloudWatchMeterRegistry(io.micrometer.cloudwatch2.CloudWatchMeterRegistry) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with DataPrepperConfiguration

use of com.amazon.dataprepper.parser.model.DataPrepperConfiguration in project data-prepper by opensearch-project.

the class MetricsConfigTest method testGivenConfigWithCloudWatchMeterRegistryThenNoMeterRegistryCreated.

@Test
public void testGivenConfigWithCloudWatchMeterRegistryThenNoMeterRegistryCreated() {
    final CloudWatchMeterRegistryProvider provider = mock(CloudWatchMeterRegistryProvider.class);
    final CloudWatchMeterRegistry expected = mock(CloudWatchMeterRegistry.class);
    final MeterRegistry.Config config = mock(MeterRegistry.Config.class);
    final DataPrepperConfiguration dataPrepperConfiguration = mock(DataPrepperConfiguration.class);
    when(provider.getCloudWatchMeterRegistry()).thenReturn(expected);
    when(expected.config()).thenReturn(config);
    when(dataPrepperConfiguration.getMetricRegistryTypes()).thenReturn(Collections.singletonList(MetricRegistryType.CloudWatch));
    final MeterRegistry meterRegistry = metricsConfig.cloudWatchMeterRegistry(dataPrepperConfiguration, provider);
    assertThat(meterRegistry, is(expected));
}
Also used : CloudWatchMeterRegistryProvider(com.amazon.dataprepper.pipeline.server.CloudWatchMeterRegistryProvider) CloudWatchMeterRegistry(io.micrometer.cloudwatch2.CloudWatchMeterRegistry) DataPrepperConfiguration(com.amazon.dataprepper.parser.model.DataPrepperConfiguration) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) EMFLoggingMeterRegistry(com.amazon.dataprepper.meter.EMFLoggingMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) CloudWatchMeterRegistry(io.micrometer.cloudwatch2.CloudWatchMeterRegistry) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with DataPrepperConfiguration

use of com.amazon.dataprepper.parser.model.DataPrepperConfiguration in project data-prepper by opensearch-project.

the class DataPrepperAppConfigurationTest method testPluginModelFromDataPrepperConfigurationAuthentication.

@Test
public void testPluginModelFromDataPrepperConfigurationAuthentication() {
    final DataPrepperConfiguration configuration = mock(DataPrepperConfiguration.class);
    final PluginModel pluginModel = appConfiguration.authentication(configuration);
    assertThat(pluginModel, is(nullValue()));
    verify(configuration).getAuthentication();
}
Also used : PluginModel(com.amazon.dataprepper.model.configuration.PluginModel) DataPrepperConfiguration(com.amazon.dataprepper.parser.model.DataPrepperConfiguration) Test(org.junit.jupiter.api.Test)

Example 9 with DataPrepperConfiguration

use of com.amazon.dataprepper.parser.model.DataPrepperConfiguration in project data-prepper by opensearch-project.

the class DataPrepperAppConfigurationTest method testGivenReturnAuthenticationThenBeanShouldEqualAuthentication.

@Test
public void testGivenReturnAuthenticationThenBeanShouldEqualAuthentication() {
    final DataPrepperConfiguration configuration = mock(DataPrepperConfiguration.class);
    final PluginModel expected = mock(PluginModel.class);
    when(configuration.getAuthentication()).thenReturn(expected);
    final PluginModel pluginModel = appConfiguration.authentication(configuration);
    assertThat(pluginModel, is(expected));
    verify(configuration).getAuthentication();
}
Also used : PluginModel(com.amazon.dataprepper.model.configuration.PluginModel) DataPrepperConfiguration(com.amazon.dataprepper.parser.model.DataPrepperConfiguration) Test(org.junit.jupiter.api.Test)

Example 10 with DataPrepperConfiguration

use of com.amazon.dataprepper.parser.model.DataPrepperConfiguration in project data-prepper by opensearch-project.

the class MetricsConfigTest method testGivenConfigWithMetricTagsThenMeterRegistryConfigured.

@ParameterizedTest
@MethodSource("provideMetricRegistryTypesAndCreators")
public void testGivenConfigWithMetricTagsThenMeterRegistryConfigured(final MetricRegistryType metricRegistryType, final Function<DataPrepperConfiguration, MeterRegistry> creator) {
    final String testKey = "testKey";
    final String testValue = "testValue";
    final String testServiceName = "testServiceName";
    final DataPrepperConfiguration dataPrepperConfiguration = mock(DataPrepperConfiguration.class);
    when(dataPrepperConfiguration.getMetricRegistryTypes()).thenReturn(Collections.singletonList(metricRegistryType));
    when(dataPrepperConfiguration.getMetricTags()).thenReturn(Map.of(testKey, testValue));
    MeterRegistry meterRegistry = creator.apply(dataPrepperConfiguration);
    Counter counter = meterRegistry.counter("counter");
    List<Tag> commonTags = counter.getId().getConventionTags(meterRegistry.config().namingConvention());
    assertThat(commonTags, equalTo(Arrays.asList(Tag.of(MetricNames.SERVICE_NAME, DataPrepper.getServiceNameForMetrics()), Tag.of(testKey, testValue))));
    when(dataPrepperConfiguration.getMetricRegistryTypes()).thenReturn(Collections.singletonList(metricRegistryType));
    when(dataPrepperConfiguration.getMetricTags()).thenReturn(Map.of(MetricNames.SERVICE_NAME, testServiceName));
    meterRegistry = creator.apply(dataPrepperConfiguration);
    counter = meterRegistry.counter("counter");
    commonTags = counter.getId().getConventionTags(meterRegistry.config().namingConvention());
    assertThat(commonTags, equalTo(List.of(Tag.of(MetricNames.SERVICE_NAME, testServiceName))));
}
Also used : Counter(io.micrometer.core.instrument.Counter) Tag(io.micrometer.core.instrument.Tag) DataPrepperConfiguration(com.amazon.dataprepper.parser.model.DataPrepperConfiguration) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) EMFLoggingMeterRegistry(com.amazon.dataprepper.meter.EMFLoggingMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) CloudWatchMeterRegistry(io.micrometer.cloudwatch2.CloudWatchMeterRegistry) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

DataPrepperConfiguration (com.amazon.dataprepper.parser.model.DataPrepperConfiguration)10 Test (org.junit.jupiter.api.Test)9 EMFLoggingMeterRegistry (com.amazon.dataprepper.meter.EMFLoggingMeterRegistry)6 CloudWatchMeterRegistry (io.micrometer.cloudwatch2.CloudWatchMeterRegistry)6 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)6 CompositeMeterRegistry (io.micrometer.core.instrument.composite.CompositeMeterRegistry)6 PrometheusMeterRegistry (io.micrometer.prometheus.PrometheusMeterRegistry)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 PluginModel (com.amazon.dataprepper.model.configuration.PluginModel)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Counter (io.micrometer.core.instrument.Counter)2 Tag (io.micrometer.core.instrument.Tag)2 CloudWatchMeterRegistryProvider (com.amazon.dataprepper.pipeline.server.CloudWatchMeterRegistryProvider)1 File (java.io.File)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1