MCPcopy Create free account
hub / github.com/apache/brpc / PrintServerSpan

Function PrintServerSpan

src/brpc/builtin/rpcz_service.cpp:360–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358}
359
360static void PrintServerSpan(std::ostream& os, const RpczSpan& span,
361 bool use_html) {
362 SpanInfoExtractor server_extr(span.info().c_str());
363 SpanInfoExtractor* extr[1] = { &server_extr };
364 int64_t last_time = span.received_real_us();
365 const butil::EndPoint remote_side(
366 butil::int2ip(span.remote_ip()), span.remote_port());
367 PrintRealDateTime(os, last_time);
368 const Protocol* protocol = FindProtocol(span.protocol());
369 const char* protocol_name = (protocol ? protocol->name : "Unknown");
370 os << " Received request(" << span.request_size() << ") from "
371 << remote_side << ' ' << protocol_name << ' ' << LOG_ID_STR << '=';
372 if (FLAGS_rpcz_hex_log_id) {
373 os << Hex(span.log_id());
374 } else {
375 os << span.log_id();
376 }
377 // TODO: We can't hyperlink parent_span now because there's no generic
378 // way to get the port of upstream server yet.
379 os << ' ' << TRACE_ID_STR << '=' << Hex(span.trace_id())
380 << ' ' << SPAN_ID_STR << '=' << Hex(span.span_id());
381 if (span.parent_span_id() != 0) {
382 os << " parent_span=" << Hex(span.parent_span_id());
383 }
384 os << std::endl;
385 if (PrintAnnotationsAndRealTimeSpan(
386 os, span.start_parse_real_us(),
387 &last_time, extr, ARRAY_SIZE(extr), &span)) {
388 os << " [Server SPAN#" << Hex(span.span_id()) << "] Processing the request in a new bthread" << std::endl;
389 }
390
391 bool entered_user_method = false;
392 if (PrintAnnotationsAndRealTimeSpan(
393 os, span.start_callback_real_us(),
394 &last_time, extr, ARRAY_SIZE(extr), &span)) {
395 entered_user_method = true;
396 os << " [Server SPAN#" << Hex(span.span_id()) << "] Enter " << WebEscape(span.full_method_name()) << std::endl;
397 }
398
399 const int nclient = span.client_spans_size();
400 for (int i = 0; i < nclient; ++i) {
401 auto& client_span = span.client_spans(i);
402 if (client_span.type() == SPAN_TYPE_CLIENT) {
403 PrintClientSpan(os, client_span, &last_time, &server_extr, use_html);
404 } else {
405 PrintBthreadSpan(os, client_span, &last_time, &server_extr, use_html);
406 }
407 }
408
409 if (PrintAnnotationsAndRealTimeSpan(
410 os, span.start_send_real_us(),
411 &last_time, extr, ARRAY_SIZE(extr), &span)) {
412 if (entered_user_method) {
413 os << " [Server SPAN#" << Hex(span.span_id()) << "] Leave " << WebEscape(span.full_method_name()) << std::endl;
414 } else {
415 os << " [Server SPAN#" << Hex(span.span_id()) << "] Responding" << std::endl;
416 }
417 }

Callers 1

default_methodMethod · 0.85

Calls 15

int2ipFunction · 0.85
PrintRealDateTimeFunction · 0.85
FindProtocolFunction · 0.85
HexClass · 0.85
WebEscapeFunction · 0.85
PrintClientSpanFunction · 0.85
PrintBthreadSpanFunction · 0.85
PrintAnnotationsFunction · 0.85
infoMethod · 0.80
received_real_usMethod · 0.80
protocolMethod · 0.80

Tested by

no test coverage detected