| 200 | } |
| 201 | |
| 202 | std::shared_ptr<Span> Span::CreateClientSpan(const std::string& full_method_name, |
| 203 | int64_t base_real_us) { |
| 204 | Span* span_raw = butil::get_object<Span>(Forbidden()); |
| 205 | if (__builtin_expect(span_raw == NULL, 0)) { |
| 206 | return nullptr; |
| 207 | } |
| 208 | std::shared_ptr<Span> span(span_raw, SpanDeleter()); |
| 209 | span->_log_id = 0; |
| 210 | span->_base_cid = INVALID_BTHREAD_ID; |
| 211 | span->_ending_cid = INVALID_BTHREAD_ID; // Client Span uses ending_cid |
| 212 | span->_type = SPAN_TYPE_CLIENT; |
| 213 | span->_async = false; |
| 214 | span->_protocol = PROTOCOL_UNKNOWN; |
| 215 | span->_error_code = 0; |
| 216 | span->_request_size = 0; |
| 217 | span->_response_size = 0; |
| 218 | span->_base_real_us = base_real_us; |
| 219 | span->_received_real_us = 0; |
| 220 | span->_start_parse_real_us = 0; |
| 221 | span->_start_callback_real_us = 0; |
| 222 | span->_start_send_real_us = 0; |
| 223 | span->_sent_real_us = 0; |
| 224 | span->_full_method_name = full_method_name; |
| 225 | span->_info.clear(); |
| 226 | std::shared_ptr<Span> parent = Span::tls_parent(); |
| 227 | if (parent) { |
| 228 | span->_trace_id = parent->trace_id(); |
| 229 | span->_parent_span_id = parent->span_id(); |
| 230 | span->_local_parent = parent; |
| 231 | { |
| 232 | BAIDU_SCOPED_LOCK(parent->_client_list_spinlock); |
| 233 | parent->_client_list.push_back(span); |
| 234 | } |
| 235 | } else { |
| 236 | span->_trace_id = GenerateTraceId(); |
| 237 | span->_parent_span_id = 0; |
| 238 | } |
| 239 | span->_span_id = GenerateSpanId(); |
| 240 | return span; |
| 241 | } |
| 242 | |
| 243 | std::shared_ptr<Span> Span::CreateBthreadSpan(const std::string& full_method_name, |
| 244 | int64_t base_real_us) { |
nothing calls this directly
no test coverage detected