diff --git a/push/include/prometheus/gateway.h b/push/include/prometheus/gateway.h index 577bfa3d..2ebd4423 100644 --- a/push/include/prometheus/gateway.h +++ b/push/include/prometheus/gateway.h @@ -15,9 +15,9 @@ class Gateway { public: using Labels = std::map; - Gateway(const std::string& uri, const std::string jobname, - const Labels& labels = {}, const std::string username = {}, - const std::string password = {}); + Gateway(const std::string host, const std::string port, + const std::string jobname, const Labels& labels = {}, + const std::string username = {}, const std::string password = {}); ~Gateway(); void RegisterCollectable(const std::weak_ptr& collectable, diff --git a/push/src/gateway.cc b/push/src/gateway.cc index 84ffd438..29b20583 100644 --- a/push/src/gateway.cc +++ b/push/src/gateway.cc @@ -14,14 +14,14 @@ namespace prometheus { static const char CONTENT_TYPE[] = "Content-Type: text/plain; version=0.0.4; charset=utf-8"; -Gateway::Gateway(const std::string& uri, const std::string jobname, - const Labels& labels, const std::string username, - const std::string password) { +Gateway::Gateway(const std::string host, const std::string port, + const std::string jobname, const Labels& labels, + const std::string username, const std::string password) { /* In windows, this will init the winsock stuff */ curl_global_init(CURL_GLOBAL_ALL); std::stringstream jobUriStream; - jobUriStream << uri << "/metrics/job/" << jobname; + jobUriStream << host << ':' << port << "/metrics/job/" << jobname; jobUri_ = jobUriStream.str(); if (!username.empty()) { diff --git a/push/tests/integration/sample_client.cc b/push/tests/integration/sample_client.cc index 5c82070a..7a0c283c 100644 --- a/push/tests/integration/sample_client.cc +++ b/push/tests/integration/sample_client.cc @@ -29,7 +29,7 @@ int main() { // create a push gateway const auto labels = Gateway::GetInstanceLabel(GetHostName()); - Gateway gateway{"127.0.0.1:9091", "sample_client", labels}; + Gateway gateway{"127.0.0.1", "9091", "sample_client", labels}; // create a metrics registry with component=main labels applied to all its // metrics