(cobra2sentry bot) remove the jobs option passed to ws, and only use one sentry sender

This commit is contained in:
Benjamin Sergeant 2020-03-12 12:24:25 -07:00
parent cb1f9f5a44
commit adf6aa1d6c
4 changed files with 6 additions and 21 deletions

View File

@ -23,7 +23,6 @@ namespace ix
const std::string& dsn, const std::string& dsn,
bool verbose, bool verbose,
bool strict, bool strict,
int jobs,
size_t maxQueueSize, size_t maxQueueSize,
bool enableHeartbeat, bool enableHeartbeat,
int runtime) int runtime)
@ -92,7 +91,7 @@ namespace ix
{ {
Json::Value msg = queueManager.pop(); Json::Value msg = queueManager.pop();
if (stop) return; if (stop) break;
if (msg.isNull()) continue; if (msg.isNull()) continue;
auto ret = sentryClient.send(msg, verbose); auto ret = sentryClient.send(msg, verbose);
@ -165,17 +164,13 @@ namespace ix
++sentCount; ++sentCount;
} }
if (stop) return; if (stop) break;
} }
spdlog::info("sentrySender thread done");
}; };
// Create a thread pool std::thread t3(sentrySender);
spdlog::info("Starting {} sentry sender jobs", jobs);
std::vector<std::thread> pool;
for (int i = 0; i < jobs; i++)
{
pool.push_back(std::thread(sentrySender));
}
conn.setEventCallback([&conn, conn.setEventCallback([&conn,
&channel, &channel,
@ -280,11 +275,7 @@ namespace ix
if (t2.joinable()) t2.join(); if (t2.joinable()) t2.join();
spdlog::info("heartbeat thread done"); spdlog::info("heartbeat thread done");
for (int i = 0; i < jobs; i++) t3.join();
{
spdlog::info("joining thread {}", i);
pool[i].join();
}
return (strict && errorSending) ? -1 : (int) sentCount; return (strict && errorSending) ? -1 : (int) sentCount;
} }

View File

@ -16,7 +16,6 @@ namespace ix
const std::string& dsn, const std::string& dsn,
bool verbose, bool verbose,
bool strict, bool strict,
int jobs,
size_t maxQueueSize, size_t maxQueueSize,
bool enableHeartbeat, bool enableHeartbeat,
int runtime); int runtime);

View File

@ -147,7 +147,6 @@ TEST_CASE("Cobra_to_sentry_bot", "[foo]")
std::string filter; std::string filter;
bool verbose = true; bool verbose = true;
bool strict = true; bool strict = true;
int jobs = 1;
size_t maxQueueSize = 10; size_t maxQueueSize = 10;
bool enableHeartbeat = false; bool enableHeartbeat = false;
@ -167,7 +166,6 @@ TEST_CASE("Cobra_to_sentry_bot", "[foo]")
dsn, dsn,
verbose, verbose,
strict, strict,
jobs,
maxQueueSize, maxQueueSize,
enableHeartbeat, enableHeartbeat,
runtime); runtime);

View File

@ -108,7 +108,6 @@ int main(int argc, char** argv)
int maxRedirects = 5; int maxRedirects = 5;
int delayMs = -1; int delayMs = -1;
int count = 1; int count = 1;
int jobs = 4;
uint32_t maxWaitBetweenReconnectionRetries; uint32_t maxWaitBetweenReconnectionRetries;
size_t maxQueueSize = 100; size_t maxQueueSize = 100;
@ -268,7 +267,6 @@ int main(int argc, char** argv)
CLI::App* cobra2sentry = app.add_subcommand("cobra_to_sentry", "Cobra metrics to sentry"); CLI::App* cobra2sentry = app.add_subcommand("cobra_to_sentry", "Cobra metrics to sentry");
cobra2sentry->add_option("--dsn", dsn, "Sentry DSN"); cobra2sentry->add_option("--dsn", dsn, "Sentry DSN");
cobra2sentry->add_option("--jobs", jobs, "Number of thread sending events to Sentry");
cobra2sentry->add_option("--queue_size", cobra2sentry->add_option("--queue_size",
maxQueueSize, maxQueueSize,
"Size of the queue to hold messages before they are sent to Sentry"); "Size of the queue to hold messages before they are sent to Sentry");
@ -455,7 +453,6 @@ int main(int argc, char** argv)
dsn, dsn,
verbose, verbose,
strict, strict,
jobs,
maxQueueSize, maxQueueSize,
enableHeartbeat, enableHeartbeat,
runtime); runtime);