use of software.amazon.awssdk.metrics.MetricCollector in project aws-sdk-java-v2 by aws.
the class DefaultMetricCollectorTest method testCreateChild_returnsChildWithCorrectName.
@Test
public void testCreateChild_returnsChildWithCorrectName() {
MetricCollector parent = MetricCollector.create("parent");
MetricCollector child = parent.createChild("child");
assertThat(child.name()).isEqualTo("child");
}
use of software.amazon.awssdk.metrics.MetricCollector in project aws-sdk-java-v2 by aws.
the class MetricUtilsTest method testCollectHttpMetrics_collectsAllExpectedMetrics.
@Test
public void testCollectHttpMetrics_collectsAllExpectedMetrics() {
MetricCollector mockCollector = mock(MetricCollector.class);
int statusCode = 200;
String requestId = "request-id";
String amznRequestId = "amzn-request-id";
String requestId2 = "request-id-2";
SdkHttpFullResponse response = SdkHttpFullResponse.builder().statusCode(statusCode).putHeader("x-amz-request-id", requestId).putHeader(HttpResponseHandler.X_AMZN_REQUEST_ID_HEADER, amznRequestId).putHeader(HttpResponseHandler.X_AMZ_ID_2_HEADER, requestId2).build();
MetricUtils.collectHttpMetrics(mockCollector, response);
verify(mockCollector).reportMetric(HttpMetric.HTTP_STATUS_CODE, statusCode);
verify(mockCollector).reportMetric(CoreMetric.AWS_REQUEST_ID, requestId);
verify(mockCollector).reportMetric(CoreMetric.AWS_REQUEST_ID, amznRequestId);
verify(mockCollector).reportMetric(CoreMetric.AWS_EXTENDED_REQUEST_ID, requestId2);
}
use of software.amazon.awssdk.metrics.MetricCollector 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.MetricCollector 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.MetricCollector in project aws-sdk-java-v2 by aws.
the class IdleConnectionCountingChannelPoolTest method getIdleConnectionCount.
private int getIdleConnectionCount() {
MetricCollector metricCollector = MetricCollector.create("test");
idleCountingPool.collectChannelPoolMetrics(metricCollector).join();
return metricCollector.collect().metricValues(HttpMetric.AVAILABLE_CONCURRENCY).get(0);
}
Aggregations