| 558 | */ |
| 559 | template<typename T, typename> |
| 560 | std::size_t OTel::Record(Gauge& gauge, T data, double start, double end, AttrsMap attrs) |
| 561 | { |
| 562 | namespace ch = std::chrono; |
| 563 | |
| 564 | auto* dataPoint = gauge.add_data_points(); |
| 565 | if constexpr (std::is_same_v<T, double>) { |
| 566 | dataPoint->set_as_double(data); |
| 567 | } else { |
| 568 | dataPoint->set_as_int(data); |
| 569 | } |
| 570 | |
| 571 | dataPoint->set_start_time_unix_nano( |
| 572 | static_cast<uint64_t>(ch::duration_cast<ch::nanoseconds>(ch::duration<double>(start)).count()) |
| 573 | ); |
| 574 | dataPoint->set_time_unix_nano( |
| 575 | static_cast<uint64_t>(ch::duration_cast<ch::nanoseconds>(ch::duration<double>(end)).count()) |
| 576 | ); |
| 577 | |
| 578 | while (!attrs.empty()) { |
| 579 | auto* attr = dataPoint->add_attributes(); |
| 580 | auto node = attrs.extract(attrs.begin()); |
| 581 | SetAttribute(*attr, std::move(node.key()), std::move(node.mapped())); |
| 582 | } |
| 583 | return dataPoint->ByteSizeLong(); |
| 584 | } |
| 585 | |
| 586 | /** |
| 587 | * Determine if the given HTTP status code represents a retryable export error as per OTel specs[^1]. |