Skip to content

Commit

Permalink
Refactor gateway ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
gjasny committed Dec 15, 2018
1 parent 09f56af commit a7b3d24
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions push/include/prometheus/gateway.h
Expand Up @@ -15,9 +15,9 @@ class Gateway {
public:
using Labels = std::map<std::string, std::string>;

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>& collectable,
Expand Down
8 changes: 4 additions & 4 deletions push/src/gateway.cc
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion push/tests/integration/sample_client.cc
Expand Up @@ -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
Expand Down

0 comments on commit a7b3d24

Please sign in to comment.