@@ -211,7 +211,15 @@ static void PrintAnnotations(
211211 PrintElapse (os, anno_time, last_time);
212212 os << ' ' ;
213213 if (span) {
214- os << ' [' << span_type_str << ' ' << SPAN_ID_STR << ' =' << Hex (span->span_id ()) << " ] " ;
214+ const char * short_type = " SPAN" ;
215+ if (span->type () == SPAN_TYPE_SERVER) {
216+ short_type = " Server" ;
217+ } else if (span->type () == SPAN_TYPE_CLIENT) {
218+ short_type = " Client" ;
219+ } else if (span->type () == SPAN_TYPE_BTHREAD) {
220+ short_type = " Bthread" ;
221+ }
222+ os << ' [' << short_type << " SPAN#" << Hex (span->span_id ()) << " ] " ;
215223 }
216224 os << WebEscape (a);
217225 if (a.empty () || butil::back_char (a) != ' \n ' ) {
@@ -292,11 +300,11 @@ static void PrintClientSpan(
292300
293301 if (PrintAnnotationsAndRealTimeSpan (os, span.sent_real_us (),
294302 last_time, extr, num_extr, &span)) {
295- os << " [ClientSpan " << SPAN_ID_STR << ' = ' << Hex (span.span_id ()) << " ] Requested(" << span.request_size () << " ) [1]" << std::endl;
303+ os << " [Client SPAN# " << Hex (span.span_id ()) << " ] Requested(" << span.request_size () << " ) [1]" << std::endl;
296304 }
297305 if (PrintAnnotationsAndRealTimeSpan (os, span.received_real_us (),
298306 last_time, extr, num_extr, &span)) {
299- os << " [ClientSpan " << SPAN_ID_STR << ' = ' << Hex (span.span_id ()) << " ] Received response(" << span.response_size () << " )" ;
307+ os << " [Client SPAN# " << Hex (span.span_id ()) << " ] Received response(" << span.response_size () << " )" ;
300308 if (span.base_cid () != 0 && span.ending_cid () != 0 ) {
301309 int64_t ver = span.ending_cid () - span.base_cid ();
302310 if (ver >= 1 ) {
@@ -310,13 +318,13 @@ static void PrintClientSpan(
310318
311319 if (PrintAnnotationsAndRealTimeSpan (os, span.start_parse_real_us (),
312320 last_time, extr, num_extr, &span)) {
313- os << " [ClientSpan " << SPAN_ID_STR << ' = ' << Hex (span.span_id ()) << " ] Processing the response in a new bthread" << std::endl;
321+ os << " [Client SPAN# " << Hex (span.span_id ()) << " ] Processing the response in a new bthread" << std::endl;
314322 }
315323
316324 if (PrintAnnotationsAndRealTimeSpan (
317325 os, span.start_callback_real_us (),
318326 last_time, extr, num_extr, &span)) {
319- os << " [ClientSpan " << SPAN_ID_STR << ' = ' << Hex (span.span_id ()) << " ] " << (span.async () ? " Enter user's done" : " Back to user's callsite" ) << std::endl;
327+ os << " [Client SPAN# " << Hex (span.span_id ()) << " ] " << (span.async () ? " Enter user's done" : " Back to user's callsite" ) << std::endl;
320328 }
321329
322330 PrintAnnotations (os, std::numeric_limits<int64_t >::max (),
@@ -340,9 +348,9 @@ static void PrintBthreadSpan(std::ostream& os, const RpczSpan& span, int64_t* la
340348 extr[num_extr++] = &client_extr;
341349
342350 // Print span id for bthread span context identification
343- os << " [BthreadSpan " << SPAN_ID_STR << ' = ' << Hex (span.span_id ());
351+ os << " [Bthread SPAN# " << Hex (span.span_id ());
344352 if (span.parent_span_id () != 0 ) {
345- os << " parent_span= " << Hex (span.parent_span_id ());
353+ os << " parent# " << Hex (span.parent_span_id ());
346354 }
347355 os << " ] " ;
348356
@@ -377,15 +385,15 @@ static void PrintServerSpan(std::ostream& os, const RpczSpan& span,
377385 if (PrintAnnotationsAndRealTimeSpan (
378386 os, span.start_parse_real_us (),
379387 &last_time, extr, ARRAY_SIZE (extr), &span)) {
380- os << " [ServerSpan " << SPAN_ID_STR << ' = ' << Hex (span.span_id ()) << " ] Processing the request in a new bthread" << std::endl;
388+ os << " [Server SPAN# " << Hex (span.span_id ()) << " ] Processing the request in a new bthread" << std::endl;
381389 }
382390
383391 bool entered_user_method = false ;
384392 if (PrintAnnotationsAndRealTimeSpan (
385393 os, span.start_callback_real_us (),
386394 &last_time, extr, ARRAY_SIZE (extr), &span)) {
387395 entered_user_method = true ;
388- os << " [ServerSpan " << SPAN_ID_STR << ' = ' << Hex (span.span_id ()) << " ] Enter " << WebEscape (span.full_method_name ()) << std::endl;
396+ os << " [Server SPAN# " << Hex (span.span_id ()) << " ] Enter " << WebEscape (span.full_method_name ()) << std::endl;
389397 }
390398
391399 const int nclient = span.client_spans_size ();
@@ -402,16 +410,16 @@ static void PrintServerSpan(std::ostream& os, const RpczSpan& span,
402410 os, span.start_send_real_us (),
403411 &last_time, extr, ARRAY_SIZE (extr), &span)) {
404412 if (entered_user_method) {
405- os << " [ServerSpan " << SPAN_ID_STR << ' = ' << Hex (span.span_id ()) << " ] Leave " << WebEscape (span.full_method_name ()) << std::endl;
413+ os << " [Server SPAN# " << Hex (span.span_id ()) << " ] Leave " << WebEscape (span.full_method_name ()) << std::endl;
406414 } else {
407- os << " [ServerSpan " << SPAN_ID_STR << ' = ' << Hex (span.span_id ()) << " ] Responding" << std::endl;
415+ os << " [Server SPAN# " << Hex (span.span_id ()) << " ] Responding" << std::endl;
408416 }
409417 }
410418
411419 if (PrintAnnotationsAndRealTimeSpan (
412420 os, span.sent_real_us (),
413421 &last_time, extr, ARRAY_SIZE (extr), &span)) {
414- os << " [ServerSpan " << SPAN_ID_STR << ' = ' << Hex (span.span_id ()) << " ] Responded(" << span.response_size () << ' )' << std::endl;
422+ os << " [Server SPAN# " << Hex (span.span_id ()) << " ] Responded(" << span.response_size () << ' )' << std::endl;
415423 }
416424
417425 PrintAnnotations (os, std::numeric_limits<int64_t >::max (),
0 commit comments