From 7f5447f25eb3e853d2aac5ae598dff6c5987300f Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Thu, 12 Aug 2021 10:55:54 +0200 Subject: [PATCH] Sentry: add debug prints for hard-debug mode --- src/THeartbeatThread.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/THeartbeatThread.cpp b/src/THeartbeatThread.cpp index ae1184e..e6c63cd 100644 --- a/src/THeartbeatThread.cpp +++ b/src/THeartbeatThread.cpp @@ -35,6 +35,21 @@ void THeartbeatThread::operator()() { Body += "&pps=" + Application::PPS(); + auto SentryReportError = [&](const std::string& transaction, int status) { + if (status < 0) { + status = 0; + } + auto Lock = Sentry.CreateExclusiveContext(); + Sentry.SetContext("heartbeat", + { { "response-body", T }, + { "request-body", Body } }); + Sentry.SetTransaction(transaction); +#if DEBUG + debug("sending log to sentry: " + std::to_string(status) + " for " + transaction); +#endif // DEBUG + Sentry.Log(SentryLevel::Error, "default", "unexpected backend response (" + std::to_string(status) + ")"); + }; + auto Target = "/heartbeat"; int ResponseCode = -1; T = Http::POST(Application::GetBackendHostname(), Target, {}, Body, false, &ResponseCode); @@ -43,16 +58,7 @@ void THeartbeatThread::operator()() { #if DEBUG debug("got " + T + " from backend"); #endif // DEBUG - auto SentryReportError = [&](const std::string& transaction, int status) { - auto Lock = Sentry.CreateExclusiveContext(); - Sentry.SetContext("heartbeat", - { { "response-body", T }, - { "request-body", Body } }); - Sentry.SetTransaction(transaction); - Sentry.Log(SentryLevel::Error, "default", "unexpected backend response (" + std::to_string(status) + ")"); - }; SentryReportError(Application::GetBackendHostname() + Target, ResponseCode); - std::this_thread::sleep_for(std::chrono::milliseconds(500)); T = Http::POST(Application::GetBackup1Hostname(), Target, {}, Body, false, &ResponseCode); if (T.substr(0, 2) != "20" || ResponseCode != 200) {