Skip to content

Commit 941e55e

Browse files
author
Krish
committed
address review comments.
1 parent 9c2d6c0 commit 941e55e

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

include/aws/s3/private/s3_request.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ struct aws_s3_request_metrics {
144144
/* The host address of the request. */
145145
struct aws_string *host_address;
146146
/* The the request ID header value. */
147-
struct aws_string *request_id;
147+
struct aws_string *request_attempt_id;
148148
/* The the extended request ID header value. */
149149
struct aws_string *amz_id_2;
150150
/* S3 operation name for the request */
@@ -158,6 +158,8 @@ struct aws_s3_request_metrics {
158158
struct aws_string *ip_address;
159159
/* The pointer to the connection that request was made from */
160160
void *connection_id;
161+
/* The pointer to the request that the request attempt was made from */
162+
void *request_id;
161163
/* The aws_thread_id_t to the thread that request ran on */
162164
aws_thread_id_t thread_id;
163165
/* The stream-id, which is the idex when the stream was activated. */
@@ -183,10 +185,6 @@ struct aws_s3_request {
183185
/* Timestamp when retry attempt ended. Overwritten on each retry and copied to new attempt's setup data.
184186
* -1 means data not available. Timestamp from `aws_high_res_clock_get_ticks` */
185187
int64_t retry_end_timestamp_ns;
186-
/* Time duration for retry attempt (retry_end_timestamp_ns - retry_start_timestamp_ns).
187-
* Overwritten on each retry and copied to new attempt's setup data.
188-
* When retry_end_timestamp_ns is -1, means data not available. */
189-
int64_t retry_duration_ns;
190188

191189
/* Linked list node used for tracking the request is active from HTTP level. */
192190
struct aws_linked_list_node cancellable_http_streams_list_node;

include/aws/s3/s3_client.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,9 +1386,9 @@ struct aws_s3_request_metrics *aws_s3_request_metrics_release(struct aws_s3_requ
13861386
* object.
13871387
**/
13881388
AWS_S3_API
1389-
int aws_s3_request_metrics_get_request_id(
1389+
int aws_s3_request_metrics_get_request_attempt_id(
13901390
const struct aws_s3_request_metrics *metrics,
1391-
const struct aws_string **out_request_id);
1391+
const struct aws_string **out_request_attempt_id);
13921392

13931393
/* Get the start time from aws_s3_request_metrics, which is when S3 client prepare the request to be sent. Always
13941394
* available. Timestamp are from `aws_high_res_clock_get_ticks` */
@@ -1568,6 +1568,10 @@ int aws_s3_request_metrics_get_ip_address(
15681568
AWS_S3_API
15691569
int aws_s3_request_metrics_get_connection_id(const struct aws_s3_request_metrics *metrics, size_t *out_connection_id);
15701570

1571+
/* Get the pointer to the request that attempt was made from. Always available. */
1572+
AWS_S3_API
1573+
int aws_s3_request_metrics_get_request_id(const struct aws_s3_request_metrics *metrics, size_t *request_id);
1574+
15711575
/* Get the thread ID of the thread that request was made from. AWS_ERROR_S3_METRIC_DATA_NOT_AVAILABLE will be raised if
15721576
* data not available */
15731577
AWS_S3_API

source/s3_request.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ struct aws_s3_request *aws_s3_request_new(
3737

3838
request->retry_start_timestamp_ns = -1;
3939
request->retry_end_timestamp_ns = -1;
40-
request->retry_duration_ns = -1;
4140

4241
request->part_number = part_number;
4342
request->record_response_headers = (flags & AWS_S3_REQUEST_FLAG_RECORD_RESPONSE_HEADERS) != 0;
@@ -139,7 +138,12 @@ void aws_s3_request_setup_send_data(struct aws_s3_request *request, struct aws_h
139138
/* copy delay duration since previous attempt */
140139
request->send_data.metrics->time_metrics.retry_delay_start_timestamp_ns = request->retry_start_timestamp_ns;
141140
request->send_data.metrics->time_metrics.retry_delay_end_timestamp_ns = request->retry_end_timestamp_ns;
142-
request->send_data.metrics->time_metrics.retry_delay_duration_ns = request->retry_duration_ns;
141+
if (request->retry_end_timestamp_ns != -1) {
142+
request->send_data.metrics->time_metrics.retry_delay_duration_ns = request->retry_end_timestamp_ns - request->retry_start_timestamp_ns;
143+
}
144+
145+
/* set pointer to request */
146+
request->send_data.metrics->crt_info_metrics.request_id = request;
143147

144148
aws_http_message_acquire(message);
145149
}
@@ -218,7 +222,7 @@ static void s_s3_request_metrics_destroy(void *arg) {
218222
aws_http_headers_release(metrics->req_resp_info_metrics.response_headers);
219223
aws_string_destroy(metrics->req_resp_info_metrics.request_path_query);
220224
aws_string_destroy(metrics->req_resp_info_metrics.host_address);
221-
aws_string_destroy(metrics->req_resp_info_metrics.request_id);
225+
aws_string_destroy(metrics->req_resp_info_metrics.request_attempt_id);
222226
aws_string_destroy(metrics->req_resp_info_metrics.amz_id_2);
223227
aws_string_destroy(metrics->req_resp_info_metrics.operation_name);
224228
aws_string_destroy(metrics->crt_info_metrics.ip_address);
@@ -291,15 +295,15 @@ struct aws_s3_request_metrics *aws_s3_request_metrics_release(struct aws_s3_requ
291295
return NULL;
292296
}
293297

294-
int aws_s3_request_metrics_get_request_id(
298+
int aws_s3_request_metrics_get_request_attempt_id(
295299
const struct aws_s3_request_metrics *metrics,
296-
const struct aws_string **out_request_id) {
300+
const struct aws_string **out_request_attempt_id) {
297301
AWS_PRECONDITION(metrics);
298-
AWS_PRECONDITION(out_request_id);
299-
if (metrics->req_resp_info_metrics.request_id == NULL) {
302+
AWS_PRECONDITION(out_request_attempt_id);
303+
if (metrics->req_resp_info_metrics.request_attempt_id == NULL) {
300304
return aws_raise_error(AWS_ERROR_S3_METRIC_DATA_NOT_AVAILABLE);
301305
}
302-
*out_request_id = metrics->req_resp_info_metrics.request_id;
306+
*out_request_attempt_id = metrics->req_resp_info_metrics.request_attempt_id;
303307
return AWS_OP_SUCCESS;
304308
}
305309

@@ -565,6 +569,18 @@ int aws_s3_request_metrics_get_connection_id(const struct aws_s3_request_metrics
565569
return AWS_OP_SUCCESS;
566570
}
567571

572+
int aws_s3_request_metrics_get_request_id(
573+
const struct aws_s3_request_metrics *metrics,
574+
const struct aws_string **out_request_id) {
575+
AWS_PRECONDITION(metrics);
576+
AWS_PRECONDITION(out_request_id);
577+
if (metrics->crt_info_metrics.request_id == NULL) {
578+
return aws_raise_error(AWS_ERROR_S3_METRIC_DATA_NOT_AVAILABLE);
579+
}
580+
*out_request_id = metrics->crt_info_metrics.request_id;
581+
return AWS_OP_SUCCESS;
582+
}
583+
568584
int aws_s3_request_metrics_get_thread_id(const struct aws_s3_request_metrics *metrics, aws_thread_id_t *thread_id) {
569585
AWS_PRECONDITION(metrics);
570586
AWS_PRECONDITION(thread_id);

0 commit comments

Comments
 (0)