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

Function PrintAnnotations

src/brpc/builtin/rpcz_service.cpp:186–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186static 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
232static bool PrintAnnotationsAndRealTimeSpan(
233 std::ostream& os, int64_t cur_time, int64_t* last_time,

Callers 4

PrintClientSpanFunction · 0.85
PrintBthreadSpanFunction · 0.85
PrintServerSpanFunction · 0.85

Calls 9

PrintRealTimeFunction · 0.85
PrintElapseFunction · 0.85
HexClass · 0.85
WebEscapeFunction · 0.85
back_charFunction · 0.85
PopAnnotationMethod · 0.80
typeMethod · 0.45
span_idMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected