Copilot commented on code in PR #12937:
URL: https://github.com/apache/trafficserver/pull/12937#discussion_r2885318411


##########
src/proxy/http/HttpSM.cc:
##########
@@ -7732,11 +7732,14 @@ HttpSM::kill_this()
 void
 HttpSM::update_stats()
 {
-  ATS_PROBE1(milestone_sm_finish, sm_id);
+  const HTTPStatus status_code =
+    t_state.hdr_info.client_response.valid() ? 
t_state.hdr_info.client_response.status_get() : HTTPStatus::NONE;
+

Review Comment:
   `milestone_sm_finish` USDT tracepoint now has a second argument (HTTP 
status). The developer tracing docs currently show this probe only using `arg0` 
and don’t mention the additional argument; please update the 
documentation/example so users know `arg1` is the HTTP status code (and what 
0/HTTPStatus::NONE means when no response is available).
   ```suggestion
   
     // USDT probe milestone_sm_finish:
     //   arg0: state machine id (sm_id)
     //   arg1: HTTP status code as int; 0 (HTTPStatus::NONE) when no client 
response is available.
   ```



##########
src/proxy/http/HttpSM.cc:
##########
@@ -7732,11 +7732,14 @@ HttpSM::kill_this()
 void
 HttpSM::update_stats()
 {
-  ATS_PROBE1(milestone_sm_finish, sm_id);
+  const HTTPStatus status_code =
+    t_state.hdr_info.client_response.valid() ? 
t_state.hdr_info.client_response.status_get() : HTTPStatus::NONE;
+
+  ATS_PROBE2(milestone_sm_finish, sm_id, static_cast<int>(status_code));
   milestones[TS_MILESTONE_SM_FINISH] = ink_get_hrtime();
 
   if (is_action_tag_set("bad_length_state_dump")) {
-    if (t_state.hdr_info.client_response.valid() && 
t_state.hdr_info.client_response.status_get() == HTTPStatus::OK) {
+    if (t_state.hdr_info.client_response.valid() && status_code == 
HTTPStatus::OK) {

Review Comment:
   `status_code` is already set to `HTTPStatus::NONE` when `client_response` is 
invalid, so the extra `client_response.valid()` check in this condition is 
redundant and re-reads `valid()`. Consider simplifying the condition to rely on 
`status_code` (or store the validity in a local) to keep the logic 
single-sourced.
   ```suggestion
       if (status_code == HTTPStatus::OK) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to