Skip to content

upgrade prometheus-cpp to v1.3.0 #4995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: v3.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ prometheus-cpp/prometheus-cpp/lib/libprometheus-cpp-core.a:
cd prometheus-cpp && tar --strip-components=1 -zxf civetweb-*.tar.gz -C prometheus-cpp/3rdparty/civetweb
cd prometheus-cpp/prometheus-cpp && patch -p1 < ../serial_exposer.patch
cd prometheus-cpp/prometheus-cpp && patch -p1 < ../registry_counters_reset.patch
cd prometheus-cpp/prometheus-cpp && patch -p1 < ../fix_old_distros.patch
# cd prometheus-cpp/prometheus-cpp && patch -p1 < ../fix_old_distros.patch

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The patch fix_old_distros.patch is no longer applied to prometheus-cpp as this line is now commented out.
Could you please clarify if this patch has become obsolete with the upgrade to prometheus-cpp v1.3.0, or if its removal might affect compatibility with older distributions? Understanding the rationale for this change would be helpful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the file fix_old_distros.patch needs to be removed?

Can we have a list of distros where this PR compiles successfully?

cd prometheus-cpp/prometheus-cpp && cmake . -DBUILD_SHARED_LIBS=OFF -DENABLE_TESTING=OFF -DENABLE_PUSH=OFF
cd prometheus-cpp/prometheus-cpp && CC=${CC} CXX=${CXX} ${MAKE}

Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion deps/prometheus-cpp/prometheus-cpp
Binary file removed deps/prometheus-cpp/prometheus-cpp-v1.1.0.tar.gz
Binary file not shown.
Binary file added deps/prometheus-cpp/prometheus-cpp-v1.3.0.tar.gz
Binary file not shown.
34 changes: 2 additions & 32 deletions deps/prometheus-cpp/registry_counters_reset.patch
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
diff --git a/core/include/prometheus/counter.h b/core/include/prometheus/counter.h
index 9b2ad19..4fa1fba 100644
--- a/core/include/prometheus/counter.h
+++ b/core/include/prometheus/counter.h
@@ -46,6 +46,12 @@ class PROMETHEUS_CPP_CORE_EXPORT Counter {
/// Collect is called by the Registry when collecting metrics.
ClientMetric Collect() const;

+ /// \brief Reset this counter metric to a value of 'zero'.
+ ///
+ /// This function shall only be used in case of 'PROXYSQL STOP' operation
+ /// which invalidates all ProxySQL internal counters for a fresh start.
+ void Reset();
+
private:
Gauge gauge_{0.0};
};
diff --git a/core/include/prometheus/family.h b/core/include/prometheus/family.h
index 0bc0723..4f62fda 100644
--- a/core/include/prometheus/family.h
+++ b/core/include/prometheus/family.h
@@ -141,6 +141,12 @@ class PROMETHEUS_CPP_CORE_EXPORT Family : public Collectable {
@@ -142,6 +142,12 @@ class PROMETHEUS_CPP_CORE_EXPORT Family : public Collectable {
/// \return Zero or more samples for each dimensional data.
std::vector<MetricFamily> Collect() const override;

Expand Down Expand Up @@ -49,24 +32,11 @@ index 6603f6c..877c085 100644
private:
template <typename T>
friend class detail::Builder;
diff --git a/core/src/counter.cc b/core/src/counter.cc
index 2a93463..a12885d 100644
--- a/core/src/counter.cc
+++ b/core/src/counter.cc
@@ -13,6 +13,8 @@ void Counter::Increment(const double val) {

double Counter::Value() const { return gauge_.Value(); }

+void Counter::Reset() { gauge_.Set(0.0); }
+
ClientMetric Counter::Collect() const {
ClientMetric metric;
metric.counter.value = Value();
diff --git a/core/src/family.cc b/core/src/family.cc
index f087586..8f9d276 100644
--- a/core/src/family.cc
+++ b/core/src/family.cc
@@ -122,6 +122,19 @@ ClientMetric Family<T>::CollectMetric(const Labels& metric_labels,
@@ -121,6 +121,19 @@ ClientMetric Family<T>::CollectMetric(const Labels& metric_labels,
return collected;
}

Expand Down
4 changes: 2 additions & 2 deletions deps/prometheus-cpp/serial_exposer.patch
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ index 38a28e0..0d62bf3 100644

#include <algorithm>
#include <iterator>
@@ -63,4 +64,28 @@ detail::Endpoint& Exposer::GetEndpointForUri(const std::string& uri) {
@@ -64,4 +65,28 @@ detail::Endpoint& Exposer::GetEndpointForUri(const std::string& uri) {
return *endpoints_.back().get();
}

Expand Down Expand Up @@ -85,7 +85,7 @@ diff --git a/pull/src/handler.cc b/pull/src/handler.cc
index 5a55001..b6ffa85 100644
--- a/pull/src/handler.cc
+++ b/pull/src/handler.cc
@@ -172,5 +172,124 @@ void MetricsHandler::CleanupStalePointers(
@@ -178,5 +178,124 @@ void MetricsHandler::CleanupStalePointers(
}),
std::end(collectables));
}
Expand Down
Loading