-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor everything to use prometheus-cpp
If only I had known about this earlier ;w;
- Loading branch information
Alexandre Flion
committed
Nov 4, 2023
1 parent
6d3d069
commit 6831719
Showing
12 changed files
with
96 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <memory> | ||
|
||
#include <prometheus/counter.h> | ||
#include <prometheus/registry.h> | ||
|
||
#include "PrometheusExporter.hpp" | ||
#include "options.hpp" | ||
|
||
PrometheusExporter::PrometheusExporter(const std::string &bind): | ||
_exposer(bind) | ||
{ | ||
} | ||
|
||
void PrometheusExporter::registerMetrics() | ||
{ | ||
_registry = std::make_shared<prometheus::Registry>(); | ||
|
||
// Just an example of what you can put here | ||
// To add anything else to the metrics follow the readme of prometheus-cpp: | ||
// https://github.com/jupp0r/prometheus-cpp/blob/master/README.md | ||
// clang-format off | ||
UNUSED auto &packet_counter = prometheus::BuildCounter() | ||
.Name("observed_packets_total") | ||
.Help("Number of observed packets") | ||
.Register(*_registry); | ||
// clang-format on | ||
|
||
_exposer.RegisterCollectable(_registry); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef D5AEBC4C_6028_4506_86F2_DA6261F54832 | ||
#define D5AEBC4C_6028_4506_86F2_DA6261F54832 | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "prometheus/exposer.h" | ||
#include "prometheus/registry.h" | ||
|
||
class PrometheusExporter { | ||
public: | ||
PrometheusExporter(const std::string &bind); | ||
void registerMetrics(); | ||
|
||
private: | ||
prometheus::Exposer _exposer; | ||
std::shared_ptr<prometheus::Registry> _registry; | ||
}; | ||
|
||
#endif /* D5AEBC4C_6028_4506_86F2_DA6261F54832 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.