From 23ae9e55dc98196abc022ba8dab8a7a6d0660db4 Mon Sep 17 00:00:00 2001 From: Ivan Kuvaldin Date: Tue, 27 Apr 2021 18:28:12 +0300 Subject: [PATCH] [Metrics] #966 Disable prometheus-cpp self-metrics Closes #966 Signed-off-by: Ivan Kuvaldin --- .../0006-prometheus-remove-self-metrics.patch | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 vcpkg/patches/0006-prometheus-remove-self-metrics.patch diff --git a/vcpkg/patches/0006-prometheus-remove-self-metrics.patch b/vcpkg/patches/0006-prometheus-remove-self-metrics.patch new file mode 100644 index 00000000000..c5b354a27ef --- /dev/null +++ b/vcpkg/patches/0006-prometheus-remove-self-metrics.patch @@ -0,0 +1,104 @@ +diff --git a/ports/prometheus-cpp/portfile.cmake b/ports/prometheus-cpp/portfile.cmake +index c6048af18..50ab2c3c6 100644 +--- a/ports/prometheus-cpp/portfile.cmake ++++ b/ports/prometheus-cpp/portfile.cmake +@@ -8,6 +8,7 @@ vcpkg_from_github( + REF v0.9.0 + SHA512 d9d5fbbd8c8aad5dd6a5e872275324d689a0c57199e4158d74e13ea62b286fa71dee01bb4197b906b79792bf1ca4e67a46b5c04621d7070241ac32876f6de891 + HEAD_REF master ++ PATCHES Add-CivetCallbacks-to-Exposer.patch remove-handler-self-metrics.patch + ) + + macro(feature FEATURENAME OPTIONNAME) +diff --git a/ports/prometheus-cpp/remove-handler-self-metrics.patch b/ports/prometheus-cpp/remove-handler-self-metrics.patch +new file mode 100644 +index 000000000..a26427035 +--- /dev/null ++++ b/ports/prometheus-cpp/remove-handler-self-metrics.patch +@@ -0,0 +1,86 @@ ++diff --git a/pull/src/handler.cc b/pull/src/handler.cc ++index cec37f3..d0b0bdf 100644 ++--- a/pull/src/handler.cc +++++ b/pull/src/handler.cc ++@@ -23,25 +23,25 @@ ++ namespace prometheus { ++ namespace detail { ++ ++-MetricsHandler::MetricsHandler(Registry& registry) ++- : bytes_transferred_family_( ++- BuildCounter() ++- .Name("exposer_transferred_bytes_total") ++- .Help("Transferred bytes to metrics services") ++- .Register(registry)), ++- bytes_transferred_(bytes_transferred_family_.Add({})), ++- num_scrapes_family_(BuildCounter() ++- .Name("exposer_scrapes_total") ++- .Help("Number of times metrics were scraped") ++- .Register(registry)), ++- num_scrapes_(num_scrapes_family_.Add({})), ++- request_latencies_family_( ++- BuildSummary() ++- .Name("exposer_request_latencies") ++- .Help("Latencies of serving scrape requests, in microseconds") ++- .Register(registry)), ++- request_latencies_(request_latencies_family_.Add( ++- {}, Summary::Quantiles{{0.5, 0.05}, {0.9, 0.01}, {0.99, 0.001}})) {} +++MetricsHandler::MetricsHandler(Registry& registry) {} +++ // : bytes_transferred_family_( +++ // BuildCounter() +++ // .Name("exposer_transferred_bytes_total") +++ // .Help("Transferred bytes to metrics services") +++ // .Register(registry)), +++ // bytes_transferred_(bytes_transferred_family_.Add({})), +++ // num_scrapes_family_(BuildCounter() +++ // .Name("exposer_scrapes_total") +++ // .Help("Number of times metrics were scraped") +++ // .Register(registry)), +++ // num_scrapes_(num_scrapes_family_.Add({})), +++ // request_latencies_family_( +++ // BuildSummary() +++ // .Name("exposer_request_latencies") +++ // .Help("Latencies of serving scrape requests, in microseconds") +++ // .Register(registry)), +++ // request_latencies_(request_latencies_family_.Add( +++ // {}, Summary::Quantiles{{0.5, 0.05}, {0.9, 0.01}, {0.99, 0.001}})) {} ++ ++ #ifdef HAVE_ZLIB ++ static bool IsEncodingAccepted(struct mg_connection* conn, ++@@ -158,10 +158,10 @@ bool MetricsHandler::handleGet(CivetServer*, struct mg_connection* conn) { ++ auto stop_time_of_request = std::chrono::steady_clock::now(); ++ auto duration = std::chrono::duration_cast( ++ stop_time_of_request - start_time_of_request); ++- request_latencies_.Observe(duration.count()); +++ // request_latencies_.Observe(duration.count()); ++ ++- bytes_transferred_.Increment(bodySize); ++- num_scrapes_.Increment(); +++ // bytes_transferred_.Increment(bodySize); +++ // num_scrapes_.Increment(); ++ return true; ++ } ++ ++diff --git a/pull/src/handler.h b/pull/src/handler.h ++index 10c90f9..94c433c 100644 ++--- a/pull/src/handler.h +++++ b/pull/src/handler.h ++@@ -28,12 +28,12 @@ class MetricsHandler : public CivetHandler { ++ ++ std::mutex collectables_mutex_; ++ std::vector> collectables_; ++- Family& bytes_transferred_family_; ++- Counter& bytes_transferred_; ++- Family& num_scrapes_family_; ++- Counter& num_scrapes_; ++- Family& request_latencies_family_; ++- Summary& request_latencies_; +++ // Family& bytes_transferred_family_; +++ // Counter& bytes_transferred_; +++ // Family& num_scrapes_family_; +++ // Counter& num_scrapes_; +++ // Family& request_latencies_family_; +++ // Summary& request_latencies_; ++ }; ++ } // namespace detail ++ } // namespace prometheus