MCPcopy Create free account
hub / github.com/Icinga/icinga2 / Record

Method Record

lib/otel/otel.cpp:560–584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

558 */
559template<typename T, typename>
560std::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].

Callers

nothing calls this directly

Calls 4

countMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
keyMethod · 0.45

Tested by

no test coverage detected