| 184 | } |
| 185 | |
| 186 | static void PrintAnnotations( |
| 187 | std::ostream& os, int64_t cur_time, int64_t* last_time, |
| 188 | SpanInfoExtractor** extractors, int num_extr, const RpczSpan* span) { |
| 189 | int64_t anno_time; |
| 190 | std::string a; |
| 191 | const char* span_type_str = "Span"; |
| 192 | if (span) { |
| 193 | switch (span->type()) { |
| 194 | case SPAN_TYPE_SERVER: |
| 195 | span_type_str = "ServerSpan"; |
| 196 | break; |
| 197 | case SPAN_TYPE_CLIENT: |
| 198 | span_type_str = "ClientSpan"; |
| 199 | break; |
| 200 | case SPAN_TYPE_BTHREAD: |
| 201 | span_type_str = "BthreadSpan"; |
| 202 | break; |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | // TODO: Going through all extractors is not strictly correct because |
| 207 | // later extractors may have earlier annotations. |
| 208 | for (int i = 0; i < num_extr; ++i) { |
| 209 | while (extractors[i]->PopAnnotation(cur_time, &anno_time, &a)) { |
| 210 | PrintRealTime(os, anno_time); |
| 211 | PrintElapse(os, anno_time, last_time); |
| 212 | os << ' '; |
| 213 | if (span) { |
| 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()) << "] "; |
| 223 | } |
| 224 | os << WebEscape(a); |
| 225 | if (a.empty() || butil::back_char(a) != '\n') { |
| 226 | os << '\n'; |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | static bool PrintAnnotationsAndRealTimeSpan( |
| 233 | std::ostream& os, int64_t cur_time, int64_t* last_time, |
no test coverage detected