use of com.amazon.dataprepper.metrics.PluginMetrics in project data-prepper by opensearch-project.
the class HTTPSourceTest method testHTTPJsonResponse415.
@Test
public void testHTTPJsonResponse415() {
// Prepare
final int testMaxPendingRequests = 1;
final int testThreadCount = 1;
final int serverTimeoutInMillis = 500;
when(sourceConfig.getRequestTimeoutInMillis()).thenReturn(serverTimeoutInMillis);
when(sourceConfig.getMaxPendingRequests()).thenReturn(testMaxPendingRequests);
when(sourceConfig.getThreadCount()).thenReturn(testThreadCount);
HTTPSourceUnderTest = new HTTPSource(sourceConfig, pluginMetrics, pluginFactory);
// Start the source
HTTPSourceUnderTest.start(testBuffer);
refreshMeasurements();
final RequestHeaders testRequestHeaders = RequestHeaders.builder().scheme(SessionProtocol.HTTP).authority("127.0.0.1:2021").method(HttpMethod.POST).path("/log/ingest").contentType(MediaType.JSON_UTF_8).build();
final HttpData testHttpData = HttpData.ofUtf8("[{\"log\": \"somelog\"}]");
// Fill in the buffer
WebClient.of().execute(testRequestHeaders, testHttpData).aggregate().whenComplete((i, ex) -> assertSecureResponseWithStatusCode(i, HttpStatus.OK)).join();
// Disable client timeout
WebClient testWebClient = WebClient.builder().responseTimeoutMillis(0).build();
// When/Then
testWebClient.execute(testRequestHeaders, testHttpData).aggregate().whenComplete((i, ex) -> assertSecureResponseWithStatusCode(i, HttpStatus.REQUEST_TIMEOUT)).join();
// verify metrics
final Measurement requestReceivedCount = MetricsTestUtil.getMeasurementFromList(requestsReceivedMeasurements, Statistic.COUNT);
Assertions.assertEquals(2.0, requestReceivedCount.getValue());
final Measurement successRequestsCount = MetricsTestUtil.getMeasurementFromList(successRequestsMeasurements, Statistic.COUNT);
Assertions.assertEquals(1.0, successRequestsCount.getValue());
final Measurement requestTimeoutsCount = MetricsTestUtil.getMeasurementFromList(requestTimeoutsMeasurements, Statistic.COUNT);
Assertions.assertEquals(1.0, requestTimeoutsCount.getValue());
final Measurement requestProcessDurationMax = MetricsTestUtil.getMeasurementFromList(requestProcessDurationMeasurements, Statistic.MAX);
final double maxDurationInMillis = 1000 * requestProcessDurationMax.getValue();
Assertions.assertTrue(maxDurationInMillis > serverTimeoutInMillis);
}
use of com.amazon.dataprepper.metrics.PluginMetrics in project data-prepper by opensearch-project.
the class PeerListProviderFactory method createProvider.
public PeerListProvider createProvider(final PluginSetting pluginSetting) {
Objects.requireNonNull(pluginSetting);
final String discoveryModeString = pluginSetting.getStringOrDefault(PeerForwarderConfig.DISCOVERY_MODE, null);
Objects.requireNonNull(discoveryModeString, String.format("Missing '%s' configuration value", PeerForwarderConfig.DISCOVERY_MODE));
final DiscoveryMode discoveryMode = DiscoveryMode.valueOf(discoveryModeString.toUpperCase());
final PluginMetrics pluginMetrics = PluginMetrics.fromPluginSetting(pluginSetting);
return discoveryMode.create(pluginSetting, pluginMetrics);
}
use of com.amazon.dataprepper.metrics.PluginMetrics in project data-prepper by opensearch-project.
the class DnsPeerListProvider_CreateTest method setup.
@BeforeEach
void setup() {
pluginSetting = new PluginSetting(PLUGIN_NAME, new HashMap<>()) {
{
setPipelineName(PIPELINE_NAME);
}
};
completableFuture = CompletableFuture.completedFuture(null);
pluginSetting.getSettings().put(PeerForwarderConfig.DISCOVERY_MODE, DiscoveryMode.DNS.toString());
pluginMetrics = mock(PluginMetrics.class);
}
use of com.amazon.dataprepper.metrics.PluginMetrics in project data-prepper by opensearch-project.
the class OTelMetricsGrpcServiceTest method setup.
@BeforeEach
public void setup() {
pluginSetting = new PluginSetting("OTelMetricsGrpcService", Collections.EMPTY_MAP);
pluginSetting.setPipelineName("pipeline");
PluginMetrics mockPluginMetrics = mock(PluginMetrics.class);
when(mockPluginMetrics.counter(OTelMetricsGrpcService.REQUESTS_RECEIVED)).thenReturn(requestsReceivedCounter);
when(mockPluginMetrics.counter(OTelMetricsGrpcService.REQUEST_TIMEOUTS)).thenReturn(timeoutCounter);
sut = new OTelMetricsGrpcService(bufferWriteTimeoutInMillis, buffer, mockPluginMetrics);
}
use of com.amazon.dataprepper.metrics.PluginMetrics in project data-prepper by opensearch-project.
the class AwsCloudMapPeerListProvider_CreateTest method setUp.
@BeforeEach
void setUp() {
pluginSetting = new PluginSetting(PLUGIN_NAME, new HashMap<>()) {
{
setPipelineName(PIPELINE_NAME);
}
};
pluginMetrics = mock(PluginMetrics.class);
pluginSetting.getSettings().put(PeerForwarderConfig.DOMAIN_NAME, ENDPOINT);
pluginSetting.getSettings().put(PeerForwarderConfig.AWS_CLOUD_MAP_NAMESPACE_NAME, UUID.randomUUID().toString());
pluginSetting.getSettings().put(PeerForwarderConfig.AWS_CLOUD_MAP_SERVICE_NAME, UUID.randomUUID().toString());
pluginSetting.getSettings().put(PeerForwarderConfig.AWS_REGION, "us-east-1");
}
Aggregations