cobra to sentry / more error handling
This commit is contained in:
parent
89909c15bc
commit
f4f3eed78d
@ -169,18 +169,15 @@ namespace ix
|
||||
std::pair<HttpResponsePtr, std::string> SentryClient::send(const Json::Value& msg,
|
||||
bool verbose)
|
||||
{
|
||||
std::string log;
|
||||
|
||||
auto args = _httpClient.createRequest();
|
||||
args->extraHeaders["X-Sentry-Auth"] = SentryClient::computeAuthHeader();
|
||||
args->connectTimeout = 60;
|
||||
args->transferTimeout = 5 * 60;
|
||||
args->followRedirects = true;
|
||||
args->verbose = verbose;
|
||||
args->logger = [&log](const std::string& msg)
|
||||
args->logger = [](const std::string& msg)
|
||||
{
|
||||
log += msg;
|
||||
std::cout << msg;
|
||||
spdlog::info("request logger: {}", msg);
|
||||
};
|
||||
|
||||
std::string body = computePayload(msg);
|
||||
@ -196,7 +193,7 @@ namespace ix
|
||||
spdlog::info("Upload size: {}", response->uploadSize);
|
||||
spdlog::info("Download size: {}", response->downloadSize);
|
||||
|
||||
std::cerr << "Status: " << response->statusCode << std::endl;
|
||||
spdlog::info("Status: {}", response->statusCode);
|
||||
if (response->errorCode != HttpErrorCode::Ok)
|
||||
{
|
||||
spdlog::info("error message: {}", response->errorMsg);
|
||||
@ -208,6 +205,6 @@ namespace ix
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair(response, log);
|
||||
return std::make_pair(response, body);
|
||||
}
|
||||
} // namespace ix
|
||||
|
@ -10,7 +10,6 @@
|
||||
#if defined(IXWEBSOCKET_USE_MBED_TLS)
|
||||
# include <mbedtls/md.h>
|
||||
#elif defined(__APPLE__)
|
||||
# include <ixwebsocket/IXSocketMbedTLS.h>
|
||||
# include <CommonCrypto/CommonHMAC.h>
|
||||
#else
|
||||
# include <openssl/hmac.h>
|
||||
|
@ -47,12 +47,12 @@ namespace ix
|
||||
std::condition_variable progressCondition;
|
||||
std::queue<Json::Value> queue;
|
||||
|
||||
SentryClient sentryClient(dsn);
|
||||
|
||||
auto sentrySender = [&condition, &progressCondition, &conditionVariableMutex,
|
||||
&queue, verbose, &errorSending, &sentCount,
|
||||
&stop, &sentryClient]
|
||||
&stop, &dsn]
|
||||
{
|
||||
SentryClient sentryClient(dsn);
|
||||
|
||||
while (true)
|
||||
{
|
||||
Json::Value msg;
|
||||
@ -70,8 +70,8 @@ namespace ix
|
||||
if (response->statusCode != 200)
|
||||
{
|
||||
spdlog::error("Error sending data to sentry: {}", response->statusCode);
|
||||
spdlog::error("Body: {}", ret.second);
|
||||
spdlog::error("Response: {}", response->payload);
|
||||
spdlog::error("Log: {}", ret.second);
|
||||
errorSending = true;
|
||||
}
|
||||
else
|
||||
@ -192,6 +192,6 @@ namespace ix
|
||||
pool[i].join();
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (strict && errorSending) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user