Skip to content

Commit

Permalink
Add CivetCallbacks to Exposer ctor, closes jupp0r#479
Browse files Browse the repository at this point in the history
Signed-off-by: kuvaldini <ivan@kuvaldini.pro>
  • Loading branch information
kuvaldini committed Apr 20, 2021
1 parent a1c9b1d commit 2865044
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions pull/include/prometheus/exposer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "prometheus/detail/pull_export.h"

class CivetServer;
class CivetCallbacks;

namespace prometheus {

Expand All @@ -20,8 +21,9 @@ class Endpoint;
class PROMETHEUS_CPP_PULL_EXPORT Exposer {
public:
explicit Exposer(const std::string& bind_address,
const std::size_t num_threads = 2);
explicit Exposer(std::vector<std::string> options);
const std::size_t num_threads = 2,
const CivetCallbacks *callbacks = nullptr);
explicit Exposer(std::vector<std::string> options, const CivetCallbacks *callbacks = nullptr);
~Exposer();
void RegisterCollectable(const std::weak_ptr<Collectable>& collectable,
const std::string& uri = std::string("/metrics"));
Expand Down
13 changes: 9 additions & 4 deletions pull/src/exposer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@

namespace prometheus {

Exposer::Exposer(const std::string& bind_address, const std::size_t num_threads)
Exposer::Exposer(const std::string& bind_address,
const std::size_t num_threads,
const CivetCallbacks *callbacks)
: Exposer(std::vector<std::string>{"listening_ports", bind_address,
"num_threads",
std::to_string(num_threads)}) {}
std::to_string(num_threads)},
callbacks) {}

Exposer::Exposer(std::vector<std::string> options)
: server_(detail::make_unique<CivetServer>(std::move(options))) {}
Exposer::Exposer(std::vector<std::string> options,
const CivetCallbacks *callbacks)
: server_(detail::make_unique<CivetServer>(std::move(options),
callbacks)) {}

Exposer::~Exposer() = default;

Expand Down

0 comments on commit 2865044

Please sign in to comment.