From 286504409e497fffe25a2946eb2c89fff2e95848 Mon Sep 17 00:00:00 2001 From: kuvaldini Date: Tue, 20 Apr 2021 19:38:13 +0300 Subject: [PATCH] Add CivetCallbacks to Exposer ctor, closes #479 Signed-off-by: kuvaldini --- pull/include/prometheus/exposer.h | 6 ++++-- pull/src/exposer.cc | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pull/include/prometheus/exposer.h b/pull/include/prometheus/exposer.h index 3e4e01c4..6a9c3ffe 100644 --- a/pull/include/prometheus/exposer.h +++ b/pull/include/prometheus/exposer.h @@ -10,6 +10,7 @@ #include "prometheus/detail/pull_export.h" class CivetServer; +class CivetCallbacks; namespace prometheus { @@ -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 options); + const std::size_t num_threads = 2, + const CivetCallbacks *callbacks = nullptr); + explicit Exposer(std::vector options, const CivetCallbacks *callbacks = nullptr); ~Exposer(); void RegisterCollectable(const std::weak_ptr& collectable, const std::string& uri = std::string("/metrics")); diff --git a/pull/src/exposer.cc b/pull/src/exposer.cc index ac53bc86..df1dbaa6 100644 --- a/pull/src/exposer.cc +++ b/pull/src/exposer.cc @@ -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{"listening_ports", bind_address, "num_threads", - std::to_string(num_threads)}) {} + std::to_string(num_threads)}, + callbacks) {} -Exposer::Exposer(std::vector options) - : server_(detail::make_unique(std::move(options))) {} +Exposer::Exposer(std::vector options, + const CivetCallbacks *callbacks) + : server_(detail::make_unique(std::move(options), + callbacks)) {} Exposer::~Exposer() = default;