use of software.amazon.awssdk.metrics.MetricCollection in project aws-sdk-java-v2 by aws.
the class NettyNioAsyncHttpClientWireMockTest method metricsAreCollectedForClosedClientCalls.
@Test
public void metricsAreCollectedForClosedClientCalls() throws Exception {
SdkAsyncHttpClient customClient = NettyNioAsyncHttpClient.builder().maxConcurrency(10).build();
customClient.close();
RecordingResponseHandler handler = makeSimpleRequestAndReturnResponseHandler(customClient);
try {
handler.executionFuture.get(10, TimeUnit.SECONDS);
} catch (Exception e) {
// Expected
}
MetricCollection metrics = handler.collector.collect();
assertThat(metrics.metricValues(HttpMetric.HTTP_CLIENT_NAME)).containsExactly("NettyNio");
assertThat(metrics.metricValues(HttpMetric.MAX_CONCURRENCY)).containsExactly(10);
assertThat(metrics.metricValues(HttpMetric.PENDING_CONCURRENCY_ACQUIRES)).containsExactly(0);
assertThat(metrics.metricValues(HttpMetric.LEASED_CONCURRENCY)).containsExactly(0);
assertThat(metrics.metricValues(HttpMetric.AVAILABLE_CONCURRENCY).get(0)).isBetween(0, 1);
}
use of software.amazon.awssdk.metrics.MetricCollection in project aws-sdk-java-v2 by aws.
the class Http2MetricsTest method maxClientStreamsHigherThanServerMaxStreamsReportServerMaxStreams.
@Test
public void maxClientStreamsHigherThanServerMaxStreamsReportServerMaxStreams() {
try (SdkAsyncHttpClient client = NettyNioAsyncHttpClient.builder().protocol(Protocol.HTTP2).maxConcurrency(10).http2Configuration(c -> c.maxStreams(3L).initialWindowSize(65535 * 3)).build()) {
MetricCollector metricCollector = MetricCollector.create("test");
client.execute(createExecuteRequest(metricCollector)).join();
MetricCollection metrics = metricCollector.collect();
assertThat(metrics.metricValues(HttpMetric.HTTP_CLIENT_NAME)).containsExactly("NettyNio");
assertThat(metrics.metricValues(HttpMetric.MAX_CONCURRENCY)).containsExactly(10);
assertThat(metrics.metricValues(HttpMetric.LEASED_CONCURRENCY).get(0)).isBetween(0, 1);
assertThat(metrics.metricValues(HttpMetric.PENDING_CONCURRENCY_ACQUIRES).get(0)).isBetween(0, 1);
assertThat(metrics.metricValues(HttpMetric.AVAILABLE_CONCURRENCY).get(0)).isIn(0, 2, 3);
assertThat(metrics.metricValues(HttpMetric.CONCURRENCY_ACQUIRE_DURATION).get(0)).isPositive();
// The stream window doesn't get initialized with the connection
// initial setting and the update appears to be asynchronous so
// this may be the default window size just based on when the
// stream window was queried or if this is the first time the
// stream is used (i.e. not previously pooled)
assertThat(metrics.metricValues(Http2Metric.LOCAL_STREAM_WINDOW_SIZE_IN_BYTES).get(0)).isIn(H2_DEFAULT_WINDOW_SIZE, 65535 * 3);
assertThat(metrics.metricValues(Http2Metric.REMOTE_STREAM_WINDOW_SIZE_IN_BYTES)).containsExactly(SERVER_INITIAL_WINDOW_SIZE);
}
}
use of software.amazon.awssdk.metrics.MetricCollection in project aws-sdk-java-v2 by aws.
the class Http2MetricsTest method maxClientStreamsLowerThanServerMaxStreamsReportClientMaxStreams.
@Test
public void maxClientStreamsLowerThanServerMaxStreamsReportClientMaxStreams() {
try (SdkAsyncHttpClient client = NettyNioAsyncHttpClient.builder().protocol(Protocol.HTTP2).maxConcurrency(10).http2Configuration(c -> c.maxStreams(1L).initialWindowSize(65535 * 3)).build()) {
MetricCollector metricCollector = MetricCollector.create("test");
client.execute(createExecuteRequest(metricCollector)).join();
MetricCollection metrics = metricCollector.collect();
assertThat(metrics.metricValues(HttpMetric.HTTP_CLIENT_NAME)).containsExactly("NettyNio");
assertThat(metrics.metricValues(HttpMetric.MAX_CONCURRENCY)).containsExactly(10);
assertThat(metrics.metricValues(HttpMetric.LEASED_CONCURRENCY).get(0)).isBetween(0, 1);
assertThat(metrics.metricValues(HttpMetric.PENDING_CONCURRENCY_ACQUIRES).get(0)).isBetween(0, 1);
assertThat(metrics.metricValues(HttpMetric.AVAILABLE_CONCURRENCY)).containsExactly(0);
assertThat(metrics.metricValues(HttpMetric.CONCURRENCY_ACQUIRE_DURATION).get(0)).isPositive();
// The stream window doesn't get initialized with the connection
// initial setting and the update appears to be asynchronous so
// this may be the default window size just based on when the
// stream window was queried or if this is the first time the
// stream is used (i.e. not previously pooled)
assertThat(metrics.metricValues(Http2Metric.LOCAL_STREAM_WINDOW_SIZE_IN_BYTES).get(0)).isIn(H2_DEFAULT_WINDOW_SIZE, 65535 * 3);
assertThat(metrics.metricValues(Http2Metric.REMOTE_STREAM_WINDOW_SIZE_IN_BYTES)).containsExactly(SERVER_INITIAL_WINDOW_SIZE);
}
}
use of software.amazon.awssdk.metrics.MetricCollection in project aws-sdk-java-v2 by aws.
the class BaseAsyncCoreMetricsTest method apiCall_operationSuccessful_addsMetrics.
@Test
public void apiCall_operationSuccessful_addsMetrics() {
stubSuccessfulResponse();
callable().get().join();
addDelayIfNeeded();
ArgumentCaptor<MetricCollection> collectionCaptor = ArgumentCaptor.forClass(MetricCollection.class);
verify(publisher()).publish(collectionCaptor.capture());
MetricCollection capturedCollection = collectionCaptor.getValue();
verifySuccessfulApiCallCollection(capturedCollection);
assertThat(capturedCollection.children()).hasSize(1);
MetricCollection attemptCollection = capturedCollection.children().get(0);
assertThat(attemptCollection.name()).isEqualTo("ApiCallAttempt");
verifySuccessfulApiCallAttemptCollection(attemptCollection);
assertThat(attemptCollection.metricValues(CoreMetric.SERVICE_CALL_DURATION).get(0)).isGreaterThanOrEqualTo(FIXED_DELAY);
}
use of software.amazon.awssdk.metrics.MetricCollection in project aws-sdk-java-v2 by aws.
the class BaseAsyncCoreMetricsTest method apiCall_allRetryAttemptsFailedOf500.
@Test
public void apiCall_allRetryAttemptsFailedOf500() {
stubErrorResponse();
assertThatThrownBy(() -> callable().get().join()).hasCauseInstanceOf(EmptyModeledException.class);
addDelayIfNeeded();
ArgumentCaptor<MetricCollection> collectionCaptor = ArgumentCaptor.forClass(MetricCollection.class);
verify(publisher()).publish(collectionCaptor.capture());
MetricCollection capturedCollection = collectionCaptor.getValue();
verifyFailedApiCallCollection(capturedCollection);
assertThat(capturedCollection.children()).hasSize(MAX_RETRIES + 1);
capturedCollection.children().forEach(this::verifyFailedApiCallAttemptCollection);
}
Aggregations