Skip to content

Commit

Permalink
Merge f06970f into 4b11ee7
Browse files Browse the repository at this point in the history
  • Loading branch information
gjasny committed May 6, 2019
2 parents 4b11ee7 + f06970f commit 33f55bc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions push/src/gateway.cc
@@ -1,6 +1,7 @@

#include "prometheus/gateway.h"

#include <memory>
#include <sstream>

#include "prometheus/client_metric.h"
Expand Down Expand Up @@ -139,7 +140,7 @@ int Gateway::push(HttpMethod method) {
auto uri = getUri(wcollectable);
auto status_code = performHttpRequest(method, uri, body);

if (status_code >= 400) {
if (status_code < 100 || status_code >= 400) {
return status_code;
}
}
Expand All @@ -162,11 +163,11 @@ std::future<int> Gateway::async_push(HttpMethod method) {
}

auto metrics = collectable->Collect();
auto body = serializer.Serialize(metrics);
auto body = std::make_shared<std::string>(serializer.Serialize(metrics));
auto uri = getUri(wcollectable);

futures.push_back(std::async(std::launch::async, [&] {
return performHttpRequest(method, uri, body);
futures.push_back(std::async(std::launch::async, [method, uri, body, this] {
return performHttpRequest(method, uri, *body);
}));
}

Expand All @@ -176,7 +177,7 @@ std::future<int> Gateway::async_push(HttpMethod method) {
for (auto& future : lfutures) {
auto status_code = future.get();

if (status_code >= 400) {
if (status_code < 100 || status_code >= 400) {
final_status_code = status_code;
}
}
Expand Down

0 comments on commit 33f55bc

Please sign in to comment.