| 263 | } |
| 264 | |
| 265 | void QueryMetricLogStatus::scheduleNext(String query_id) |
| 266 | { |
| 267 | info.next_collect_time += std::chrono::milliseconds(info.interval_milliseconds); |
| 268 | const auto now = std::chrono::system_clock::now(); |
| 269 | if (info.next_collect_time > now) |
| 270 | { |
| 271 | const auto wait_time = std::chrono::duration_cast<std::chrono::milliseconds>(info.next_collect_time - now).count(); |
| 272 | LOG_TEST(logger, "Scheduling next collecting task for query_id {} in {} ms", query_id, wait_time); |
| 273 | info.task->scheduleAfter(wait_time); |
| 274 | } |
| 275 | else |
| 276 | { |
| 277 | LOG_TEST(logger, "The next collecting task for query {} should have already run at {}. Scheduling it right now", |
| 278 | query_id, timePointToString(info.next_collect_time)); |
| 279 | |
| 280 | /// Skipping lost runs |
| 281 | info.next_collect_time = now; |
| 282 | info.task->schedule(); |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | std::optional<QueryMetricLogElement> QueryMetricLogStatus::createLogMetricElement( |
| 287 | const String & query_id, |
no test coverage detected