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()));
}
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));
}
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();
}
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();
}
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))));
}
Aggregations