add Prometheus/OpenMetrics exporter (#3081)

* add prometheus endpoint

* refine metrics implementation

* move metrics generator to ClassFlowControll

* add more metrics
align prefix

* add more metrics
clean up

* refine documentation

* revert dependencies change

* sanitize labels

* create separate module for openmetrics

* move openmetrics to separate folder

* clean up

* add basic unit-tests

* work with const numbers
add replaceAll for string replacement
avoid opening std namespace
adapt unit-tests

* Update code/main/server_main.cpp

---------

Co-authored-by: CaCO3 <caco3@ruinelli.ch>
This commit is contained in:
Henry Thasler
2024-06-02 21:13:15 +02:00
committed by GitHub
parent 1300242d4a
commit 1a76ae121c
13 changed files with 228 additions and 2 deletions

View File

@@ -1206,3 +1206,13 @@ bool isInString(std::string &s, std::string const &toFind)
return true;
}
// from https://stackoverflow.com/a/14678800
void replaceAll(std::string& s, const std::string& toReplace, const std::string& replaceWith)
{
size_t pos = 0;
while ((pos = s.find(toReplace, pos)) != std::string::npos) {
s.replace(pos, toReplace.length(), replaceWith);
pos += replaceWith.length();
}
}