C++ Actor Framework 1.0.0
|
Collects system metrics and exports them to the text-based Prometheus format. More...
#include <prometheus.hpp>
Public Types | |
using | char_buffer = std::vector<char> |
A buffer for storing UTF-8 characters. | |
Public Member Functions | |
timespan | min_scrape_interval () const noexcept |
Returns the minimum scrape interval, i.e., the minimum time that needs to pass before collect_from iterates the registry to re-fill the buffer. | |
void | min_scrape_interval (timespan value) noexcept |
Sets the minimum scrape interval to value . | |
timestamp | last_scrape () const noexcept |
Returns the time point of the last scrape. | |
std::string_view | str () const noexcept |
Returns a string view into the internal buffer. | |
void | reset () |
Reverts the collector back to its initial state, clearing all buffers. | |
bool | begin_scrape (timestamp now=make_timestamp()) |
Begins a new scrape if last_scape() + min_scrape_interval() <= now . | |
void | end_scrape () |
Cleans up any temporary state before accessing str() for obtaining the scrape result. | |
template<class T > | |
void | append_counter (const metric_family *family, const metric *instance, T value) |
template<class T > | |
void | append_gauge (const metric_family *family, const metric *instance, T value) |
void | append_histogram (const metric_family *family, const metric *instance, span< const int_histogram::bucket_type > buckets, int64_t sum) |
void | append_histogram (const metric_family *family, const metric *instance, span< const dbl_histogram::bucket_type > buckets, double sum) |
std::string_view | collect_from (const metric_registry ®istry, timestamp now=make_timestamp()) |
Applies this collector to the registry, filling the character buffer while collecting metrics. | |
void | operator() (const metric_family *family, const metric *instance, const dbl_counter *counter) |
void | operator() (const metric_family *family, const metric *instance, const int_counter *counter) |
void | operator() (const metric_family *family, const metric *instance, const dbl_gauge *gauge) |
void | operator() (const metric_family *family, const metric *instance, const int_gauge *gauge) |
void | operator() (const metric_family *family, const metric *instance, const dbl_histogram *val) |
void | operator() (const metric_family *family, const metric *instance, const int_histogram *val) |
Collects system metrics and exports them to the text-based Prometheus format.
For a documentation of the format, see: https://git.io/fjgDD.
using caf::telemetry::collector::prometheus::char_buffer = std::vector<char> |
A buffer for storing UTF-8 characters.
Using a vector instead of a std::string
has slight performance benefits, since the vector does not have to maintain a null-terminator.
|
nodiscard |
Begins a new scrape if last_scape() + min_scrape_interval() <= now
.
true
if the collector started a new scrape or false
to signal that the caller shall use the last result via str()
since it has not expired yet. std::string_view caf::telemetry::collector::prometheus::collect_from | ( | const metric_registry & | registry, |
timestamp | now = make_timestamp() ) |
Applies this collector to the registry, filling the character buffer while collecting metrics.
Automatically calls begin_scrape
and end_scrape
as needed.
registry | Source for the metrics. |
now | Current system time. |
|
nodiscardnoexcept |
Returns a string view into the internal buffer.