| 257 | static int ALLOW_UNUSED init_loopback_ip_dummy = butil::str2ip("127.0.0.1", &loopback_ip); |
| 258 | |
| 259 | static void PrintClientSpan( |
| 260 | std::ostream& os, const RpczSpan& span, |
| 261 | int64_t* last_time, SpanInfoExtractor* server_extr, bool use_html) { |
| 262 | SpanInfoExtractor client_extr(span.info().c_str()); |
| 263 | int num_extr = 0; |
| 264 | SpanInfoExtractor* extr[2]; |
| 265 | if (server_extr) { |
| 266 | extr[num_extr++] = server_extr; |
| 267 | } |
| 268 | extr[num_extr++] = &client_extr; |
| 269 | if (!PrintAnnotationsAndRealTimeSpan(os, span.start_send_real_us(), |
| 270 | last_time, extr, num_extr, &span)) { |
| 271 | os << " start_send_real_us:not-set"; |
| 272 | } |
| 273 | const Protocol* protocol = FindProtocol(span.protocol()); |
| 274 | const char* protocol_name = (protocol ? protocol->name : "Unknown"); |
| 275 | const butil::EndPoint remote_side(butil::int2ip(span.remote_ip()), span.remote_port()); |
| 276 | butil::EndPoint abs_remote_side = remote_side; |
| 277 | if (abs_remote_side.ip == loopback_ip) { |
| 278 | abs_remote_side.ip = butil::my_ip(); |
| 279 | } |
| 280 | os << " Requesting " << WebEscape(span.full_method_name()) << '@' << remote_side |
| 281 | << ' ' << protocol_name << ' ' << LOG_ID_STR << '='; |
| 282 | if (FLAGS_rpcz_hex_log_id) { |
| 283 | os << Hex(span.log_id()); |
| 284 | } else { |
| 285 | os << span.log_id(); |
| 286 | } |
| 287 | os << " call_id=" << span.base_cid() |
| 288 | << ' ' << TRACE_ID_STR << '=' << Hex(span.trace_id()) |
| 289 | << ' ' << SPAN_ID_STR << '='; |
| 290 | if (use_html) { |
| 291 | os << "<a href=\"http://" << abs_remote_side |
| 292 | << "/rpcz?" << TRACE_ID_STR << '=' << Hex(span.trace_id()) |
| 293 | << '&' << SPAN_ID_STR << '=' << Hex(span.span_id()) << "\">"; |
| 294 | } |
| 295 | os << Hex(span.span_id()); |
| 296 | if (use_html) { |
| 297 | os << "</a>"; |
| 298 | } |
| 299 | os << std::endl; |
| 300 | |
| 301 | if (PrintAnnotationsAndRealTimeSpan(os, span.sent_real_us(), |
| 302 | last_time, extr, num_extr, &span)) { |
| 303 | os << " [Client SPAN#" << Hex(span.span_id()) << "] Requested(" << span.request_size() << ") [1]" << std::endl; |
| 304 | } |
| 305 | if (PrintAnnotationsAndRealTimeSpan(os, span.received_real_us(), |
| 306 | last_time, extr, num_extr, &span)) { |
| 307 | os << " [Client SPAN#" << Hex(span.span_id()) << "] Received response(" << span.response_size() << ")"; |
| 308 | if (span.base_cid() != 0 && span.ending_cid() != 0) { |
| 309 | int64_t ver = span.ending_cid() - span.base_cid(); |
| 310 | if (ver >= 1) { |
| 311 | os << " of request[" << ver << "]"; |
| 312 | } else { |
| 313 | os << " of invalid version=" << ver; |
| 314 | } |
| 315 | } |
| 316 | os << std::endl; |
no test coverage detected