lh2debug commented on code in PR #3140:
URL: https://github.com/apache/brpc/pull/3140#discussion_r2522340078


##########
src/brpc/builtin/rpcz_service.cpp:
##########
@@ -372,22 +400,22 @@ static void PrintServerSpan(std::ostream& os, const 
RpczSpan& span,
 
     if (PrintAnnotationsAndRealTimeSpan(
             os, span.start_send_real_us(),
-            &last_time, extr, ARRAY_SIZE(extr))) {
+            &last_time, extr, ARRAY_SIZE(extr), &span)) {
         if (entered_user_method) {
-            os << " Leave " << WebEscape(span.full_method_name()) << std::endl;
+            os << " [ServerSpan " << SPAN_ID_STR << '=' << Hex(span.span_id()) 
<< "] Leave " << WebEscape(span.full_method_name()) << std::endl;
         } else {
-            os << " Responding" << std::endl;
+            os << " [ServerSpan " << SPAN_ID_STR << '=' << Hex(span.span_id()) 
<< "] Responding" << std::endl;
         }
     }
     
     if (PrintAnnotationsAndRealTimeSpan(
             os, span.sent_real_us(),
-            &last_time, extr, ARRAY_SIZE(extr))) {
-        os << " Responded(" << span.response_size() << ')' << std::endl;
+            &last_time, extr, ARRAY_SIZE(extr), &span)) {

Review Comment:
   As shown below, the type of span (server span, client span, bthread span) is 
indicated at the beginning to facilitate troubleshooting.
   
   ```
   Fetching new trace TRACE#B from HOST#X
   
   Received request REQ#65674 from HOST#Y via PROTO#1 log=0 trace=TRACE#B 
span=SPAN#S1
   
   [ServerSpan span=SPAN#S1] Processing the request in a new worker
   [ServerSpan span=SPAN#S1] ParseStats[cut=?, queue=?, worker=?, rpc=?]
   [ServerSpan span=SPAN#S1] Enter Ecom.OrderService.PlaceOrder
   
   [ClientSpan span=SPAN#C1] Cart.AddItem item=ITEM# qty=QTY# price=PRICE# 
user=USER# session=SESSION#
   [ClientSpan span=SPAN#C1] Cart.VerifyOperation item=ITEM# op=OP# user=USER# 
session=SESSION#
   [ClientSpan span=SPAN#C1] Cart.ProposeUpdate item=ITEM# op=OP# user=USER# 
session=SESSION# attempt=SN#
   [ClientSpan span=SPAN#C1] Orchestration.Manager: enqueue step=PlaceOrder 
first=I# last=I#
   [ClientSpan span=SPAN#C1] Orchestration.Queue: pending step
   
   Requesting Ecom.Consensus.Append@HOST#Z PROTO#1 call=CALL# trace=TRACE#B 
span=SPAN#C1
   [ClientSpan span=SPAN#C1] Requested(REQ#65778) [1]
   [ClientSpan span=SPAN#C1] Received response(RSP#) of request[1]
   [ClientSpan span=SPAN#C1] Processing the response in a new worker
   [ClientSpan span=SPAN#C1] Enter client callback
   
   [ClientSpan span=SPAN#C1] Workflow.OnApply, ongoing tasks: 0
   [ClientSpan span=SPAN#C1] TaskQueue status running=R# queues=Q# active=A#
   [ClientSpan span=SPAN#C1] OrderPipeline.WriteOrder
   [ClientSpan span=SPAN#C1] Payment.Authorize
   [ClientSpan span=SPAN#C1] Inventory.Reserve
   [ClientSpan span=SPAN#C1] Promotion.Apply
   [ClientSpan span=SPAN#C1] Promotion.Apply_done
   [ClientSpan span=SPAN#C1] Notification.Prepare
   [ClientSpan span=SPAN#C1] Notification.Prepare_done
   [ClientSpan span=SPAN#C1] Inventory.Reserve_done
   [ClientSpan span=SPAN#C1] Payment.Authorize_done
   [ClientSpan span=SPAN#C1] OrderPipeline.Sync
   [ClientSpan span=SPAN#C1] OrderPipeline.WriteOrder done (~2.7ms)
   [ClientSpan span=SPAN#C1] Latency stats: avg≈58us p90≈66us p99≈160us
   [ClientSpan span=SPAN#C1] Protocol response before join
   [ClientSpan span=SPAN#C1] Protocol response after join
   
   [ClientSpan span=SPAN#C1] FulfillmentWorker: ongoing tasks=3
   [ClientSpan span=SPAN#C1] FulfillmentWorker: global queue running=R# 
queues=Q# active=A#
   [ClientSpan span=SPAN#C1] FulfillmentWorker: enter
   [ClientSpan span=SPAN#C1] Batcher.append
   [ClientSpan span=SPAN#C1] Batcher.flush queue_wait≈~6.7ms
   
   Requesting Ecom.Consensus.Append@HOST#Y PROTO#1 call=CALL# trace=TRACE#B 
span=SPAN#C2
   [ClientSpan span=SPAN#C2] Requested(REQ#65778) [1]
   [ClientSpan span=SPAN#C2] Received response(RSP#) of request[1]
   [ClientSpan span=SPAN#C2] Processing the response in a new worker
   [ClientSpan span=SPAN#C2] Enter client callback
   
   [ServerSpan span=SPAN#S1] Leave Ecom.OrderService.PlaceOrder
   [ServerSpan span=SPAN#S1] Responded
   ```



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to