diff --git a/push/include/prometheus/gateway.h b/push/include/prometheus/gateway.h index 577bfa3d..53cfc648 100644 --- a/push/include/prometheus/gateway.h +++ b/push/include/prometheus/gateway.h @@ -25,21 +25,15 @@ class Gateway { static const Labels GetInstanceLabel(std::string hostname); - enum class HttpMethod { - Post, - Put, - Delete, - }; - // Push metrics to the given pushgateway. - int Push() { return push(HttpMethod::Post); } + int Push(); - std::future AsyncPush() { return async_push(HttpMethod::Post); } + std::future AsyncPush(); // PushAdd metrics to the given pushgateway. - int PushAdd() { return push(HttpMethod::Put); } + int PushAdd(); - std::future AsyncPushAdd() { return async_push(HttpMethod::Put); } + std::future AsyncPushAdd(); // Delete metrics from the given pushgateway. int Delete(); @@ -57,6 +51,12 @@ class Gateway { std::string getUri(const CollectableEntry& collectable) const; + enum class HttpMethod { + Post, + Put, + Delete, + }; + int performHttpRequest(HttpMethod method, const std::string& uri, const std::string& body) const; diff --git a/push/src/gateway.cc b/push/src/gateway.cc index 84ffd438..59680daa 100644 --- a/push/src/gateway.cc +++ b/push/src/gateway.cc @@ -121,6 +121,10 @@ std::string Gateway::getUri(const CollectableEntry& collectable) const { return uri.str(); } +int Gateway::Push() { return push(HttpMethod::Post); } + +int Gateway::PushAdd() { return push(HttpMethod::Put); } + int Gateway::push(HttpMethod method) { const auto serializer = TextSerializer{}; @@ -143,6 +147,10 @@ int Gateway::push(HttpMethod method) { return 200; } +std::future Gateway::AsyncPush() { return async_push(HttpMethod::Post); } + +std::future Gateway::AsyncPushAdd() { return async_push(HttpMethod::Put); } + std::future Gateway::async_push(HttpMethod method) { const auto serializer = TextSerializer{}; std::vector> futures;