Skip to content

Commit 82fb7ed

Browse files
Added leased_concurrency to metrics and instrumented http connection manager and stream managers. (#392)
1 parent db41119 commit 82fb7ed

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

include/aws/http/connection_manager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ struct aws_http_manager_metrics {
4040
size_t available_concurrency;
4141
/* The number of requests that are awaiting concurrency to be made available from the HTTP manager. */
4242
size_t pending_concurrency_acquires;
43+
/* The number of connections (http/1.1) or streams (for h2 via. stream manager) currently vended to user. */
44+
size_t leased_concurrency;
4345
};
4446

4547
/*

source/connection_manager.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ struct aws_http_connection_manager {
176176
/*
177177
* The number of all established, idle connections. So
178178
* that we don't have compute the size of a linked list every time.
179-
* It doesn't contribute to internal refcount as AWS_HCMCT_OPEN_CONNECTION inclues all idle connections as well.
179+
* It doesn't contribute to internal refcount as AWS_HCMCT_OPEN_CONNECTION includes all idle connections as well.
180180
*/
181181
size_t idle_connection_count;
182182

@@ -1555,5 +1555,6 @@ void aws_http_connection_manager_fetch_metrics(
15551555
AWS_FATAL_ASSERT(aws_mutex_lock((struct aws_mutex *)(void *)&manager->lock) == AWS_OP_SUCCESS);
15561556
out_metrics->available_concurrency = manager->idle_connection_count;
15571557
out_metrics->pending_concurrency_acquires = manager->pending_acquisition_count;
1558+
out_metrics->leased_concurrency = manager->internal_ref[AWS_HCMCT_VENDED_CONNECTION];
15581559
AWS_FATAL_ASSERT(aws_mutex_unlock((struct aws_mutex *)(void *)&manager->lock) == AWS_OP_SUCCESS);
15591560
}

source/http2_stream_manager.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,7 @@ void aws_http2_stream_manager_fetch_metrics(
12311231
out_metrics->pending_concurrency_acquires =
12321232
stream_manager->synced_data.internal_refcount_stats[AWS_SMCT_PENDING_ACQUISITION];
12331233
out_metrics->available_concurrency = all_available_streams_num;
1234+
out_metrics->leased_concurrency = stream_manager->synced_data.internal_refcount_stats[AWS_SMCT_OPEN_STREAM];
12341235
s_unlock_synced_data((struct aws_http2_stream_manager *)(void *)stream_manager);
12351236
} /* END CRITICAL SECTION */
12361237
}

tests/test_stream_manager.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ TEST_CASE(h2_sm_mock_fetch_metric) {
893893
/* Acquired 1 stream, and we hold one connection, the max streams per connection is 2. */
894894
ASSERT_UINT_EQUALS(out_metrics.available_concurrency, 1);
895895
ASSERT_UINT_EQUALS(out_metrics.pending_concurrency_acquires, 0);
896+
ASSERT_UINT_EQUALS(out_metrics.leased_concurrency, 1);
896897

897898
ASSERT_SUCCESS(s_sm_stream_acquiring(1));
898899

@@ -902,6 +903,7 @@ TEST_CASE(h2_sm_mock_fetch_metric) {
902903
aws_http2_stream_manager_fetch_metrics(s_tester.stream_manager, &out_metrics);
903904
ASSERT_UINT_EQUALS(out_metrics.available_concurrency, 0);
904905
ASSERT_UINT_EQUALS(out_metrics.pending_concurrency_acquires, 0);
906+
ASSERT_UINT_EQUALS(out_metrics.leased_concurrency, 2);
905907

906908
ASSERT_SUCCESS(s_sm_stream_acquiring(10));
907909
ASSERT_SUCCESS(s_wait_on_fake_connection_count(5));
@@ -910,6 +912,7 @@ TEST_CASE(h2_sm_mock_fetch_metric) {
910912
aws_http2_stream_manager_fetch_metrics(s_tester.stream_manager, &out_metrics);
911913
ASSERT_UINT_EQUALS(out_metrics.available_concurrency, 0);
912914
ASSERT_UINT_EQUALS(out_metrics.pending_concurrency_acquires, 2);
915+
ASSERT_UINT_EQUALS(out_metrics.leased_concurrency, 10);
913916

914917
ASSERT_SUCCESS(s_complete_all_fake_connection_streams());
915918
/* Still have two more streams that have not been completed */

0 commit comments

Comments
 (0)