Rework everything to access the prometheus-cpp objects more directly

This commit is contained in:
Tim Wojtulewicz 2024-03-26 11:19:25 -07:00
parent ec3e68928f
commit 84aa308527
17 changed files with 469 additions and 606 deletions

30
src/telemetry/Utils.h Normal file
View file

@ -0,0 +1,30 @@
#pragma once
#include <string_view>
#include "zeek/Span.h"
#include "zeek/Val.h"
#include "prometheus/family.h"
#include "prometheus/labels.h"
namespace zeek::telemetry {
using LabelView = std::pair<std::string_view, std::string_view>;
namespace detail {
/**
* Builds a set of labels for prometheus based on a set of labels from
* Zeek. This adds an 'endpoint' label if it's missing from the set.
*/
prometheus::Labels BuildPrometheusLabels(Span<const LabelView> labels);
/**
* Builds a full metric name for Prometheus from prefix, name, and unit values.
*/
std::string BuildFullPrometheusName(std::string_view prefix, std::string_view name, std::string_view unit,
bool is_sum = false);
} // namespace detail
} // namespace zeek::telemetry