7#include "CivetServer.h"
8#include "prometheus/collectable.h"
9#include "prometheus/counter.h"
10#include "prometheus/family.h"
11#include "prometheus/registry.h"
12#include "prometheus/summary.h"
14namespace prometheus::detail {
15class MetricsHandler :
public CivetHandler {
17 explicit MetricsHandler(Registry& registry);
19 void RegisterCollectable(
const std::weak_ptr<Collectable>& collectable);
20 void RemoveCollectable(
const std::weak_ptr<Collectable>& collectable);
22 bool handleGet(CivetServer* server,
struct mg_connection* conn)
override;
25 static void CleanupStalePointers(
26 std::vector<std::weak_ptr<Collectable>>& collectables);
28 std::mutex collectables_mutex_;
29 std::vector<std::weak_ptr<Collectable>> collectables_;
30 Family<Counter>& bytes_transferred_family_;
31 Counter& bytes_transferred_;
32 Family<Counter>& num_scrapes_family_;
33 Counter& num_scrapes_;
34 Family<Summary>& request_latencies_family_;
35 Summary& request_latencies_;