Prometheus Client Library for Modern C++
Loading...
Searching...
No Matches
endpoint.h
1#pragma once
2
3#include <functional>
4#include <memory>
5#include <string>
6
7#include "CivetServer.h"
8#include "basic_auth.h"
9#include "prometheus/collectable.h"
10#include "prometheus/registry.h"
11
12namespace prometheus {
13namespace detail {
14class MetricsHandler;
15
16class Endpoint {
17 public:
18 explicit Endpoint(CivetServer& server, std::string uri);
19 ~Endpoint();
20
21 Endpoint(const Endpoint&) = delete;
22 Endpoint(Endpoint&&) = delete;
23 Endpoint& operator=(const Endpoint&) = delete;
24 Endpoint& operator=(Endpoint&&) = delete;
25
26 void RegisterCollectable(const std::weak_ptr<Collectable>& collectable);
27 void RegisterAuth(
28 std::function<bool(const std::string&, const std::string&)> authCB,
29 const std::string& realm);
30 void RemoveCollectable(const std::weak_ptr<Collectable>& collectable);
31
32 const std::string& GetURI() const;
33
34 private:
35 CivetServer& server_;
36 const std::string uri_;
37 // registry for "meta" metrics about the endpoint itself
38 std::shared_ptr<Registry> endpoint_registry_;
39 std::unique_ptr<MetricsHandler> metrics_handler_;
40 std::unique_ptr<BasicAuthHandler> auth_handler_;
41};
42
43} // namespace detail
44} // namespace prometheus