| 503 | } |
| 504 | |
| 505 | bool Trace::end() { |
| 506 | if (ended_.exchange(true)) |
| 507 | return true; |
| 508 | |
| 509 | JsonValue batch = JsonValue::array(); |
| 510 | { |
| 511 | std::lock_guard<std::mutex> lock(mu_); |
| 512 | batch.push_back(build_trace_event()); |
| 513 | for (auto& ev : events_) |
| 514 | batch.push_back(std::move(ev)); |
| 515 | events_.clear(); |
| 516 | } |
| 517 | |
| 518 | bool ok = tracer_.send_batch(batch); |
| 519 | return ok || |
| 520 | tracer_.config().error_policy == Config::ErrorPolicy::kBestEffort; |
| 521 | } |
| 522 | |
| 523 | std::string Trace::to_iso8601(std::chrono::system_clock::time_point t) { |
| 524 | auto tt = std::chrono::system_clock::to_time_t(t); |