From 111475e65c30e23bd215db9dff515f88e680895b Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Tue, 18 Feb 2020 12:40:46 -0800 Subject: [PATCH] (ws cobra to statsd and sentry sender) exit if no messages are received for one minute, which is a sign that something goes wrong on the server side. That should be changed to be configurable in the future --- docs/CHANGELOG.md | 4 ++++ ixwebsocket/IXWebSocketVersion.h | 2 +- ws/ws_cobra_to_sentry.cpp | 25 +++++++++++++++++++++++++ ws/ws_cobra_to_statsd.cpp | 27 ++++++++++++++++++++++++++- 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b02556a4..422f8183 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All changes to this project will be documented in this file. +## [8.1.1] - 2020-02-18 + +(ws cobra to statsd and sentry sender) exit if no messages are received for one minute, which is a sign that something goes wrong on the server side. That should be changed to be configurable in the future + ## [8.1.0] - 2020-02-13 (http client + sentry minidump upload) Multipart stream closing boundary is invalid + mark some options as mandatory in the command line tools diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index ab676371..b31f98cc 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "8.1.0" +#define IX_WEBSOCKET_VERSION "8.1.1" diff --git a/ws/ws_cobra_to_sentry.cpp b/ws/ws_cobra_to_sentry.cpp index 8aed37aa..f6681c4e 100644 --- a/ws/ws_cobra_to_sentry.cpp +++ b/ws/ws_cobra_to_sentry.cpp @@ -135,6 +135,31 @@ namespace ix std::thread t1(timer); + auto heartbeat = [&sentCount, &receivedCount] { + std::string state("na"); + + while (true) + { + std::stringstream ss; + ss << "messages received " << receivedCount; + ss << "messages sent " << sentCount; + + std::string currentState = ss.str(); + + if (currentState == state) + { + spdlog::error("no messages received or sent for 1 minute, exiting"); + exit(1); + } + state = currentState; + + auto duration = std::chrono::minutes(1); + std::this_thread::sleep_for(duration); + } + }; + + std::thread t2(heartbeat); + auto sentrySender = [&queueManager, verbose, &errorSending, &sentCount, &stop, &throttled, &dsn] { SentryClient sentryClient(dsn); diff --git a/ws/ws_cobra_to_statsd.cpp b/ws/ws_cobra_to_statsd.cpp index 53d090fc..aa457d49 100644 --- a/ws/ws_cobra_to_statsd.cpp +++ b/ws/ws_cobra_to_statsd.cpp @@ -153,6 +153,31 @@ namespace ix std::thread t1(timer); + auto heartbeat = [&sentCount, &receivedCount] { + std::string state("na"); + + while (true) + { + std::stringstream ss; + ss << "messages received " << receivedCount; + ss << "messages sent " << sentCount; + + std::string currentState = ss.str(); + + if (currentState == state) + { + spdlog::error("no messages received or sent for 1 minute, exiting"); + exit(1); + } + state = currentState; + + auto duration = std::chrono::minutes(1); + std::this_thread::sleep_for(duration); + } + }; + + std::thread t2(heartbeat); + auto statsdSender = [&queueManager, &host, &port, &sentCount, &tokens, &prefix, &stop] { // statsd client // test with netcat as a server: `nc -ul 8125` @@ -184,7 +209,7 @@ namespace ix } }; - std::thread t2(statsdSender); + std::thread t3(statsdSender); conn.setEventCallback( [&conn, &channel, &filter, &jsonWriter, verbose, &queueManager, &receivedCount](