diff --git a/ixbots/ixbots/IXCobraMetricsToStatsdBot.cpp b/ixbots/ixbots/IXCobraMetricsToStatsdBot.cpp index e233f46f..ead09300 100644 --- a/ixbots/ixbots/IXCobraMetricsToStatsdBot.cpp +++ b/ixbots/ixbots/IXCobraMetricsToStatsdBot.cpp @@ -14,6 +14,19 @@ #include #include +namespace +{ + std::string removeSpaces(const std::string& str) + { + std::string out(str); + out.erase( + std::remove_if(out.begin(), out.end(), [](unsigned char x) { return std::isspace(x); }), + out.end()); + + return out; + } +} + namespace ix { bool processPerfMetricsEvent(const Json::Value& msg, @@ -35,7 +48,7 @@ namespace ix ss << msg["id"].asString() << "." << msg["device"]["game"].asString() << "." << msg["device"]["os_name"].asString() << "." - << msg["data"]["Tag"].asString(); + << removeSpaces(msg["data"]["Tag"].asString()); std::string id = ss.str(); diff --git a/ixbots/ixbots/IXStatsdClient.cpp b/ixbots/ixbots/IXStatsdClient.cpp index bc98951e..85a7fc61 100644 --- a/ixbots/ixbots/IXStatsdClient.cpp +++ b/ixbots/ixbots/IXStatsdClient.cpp @@ -48,11 +48,15 @@ namespace ix { - StatsdClient::StatsdClient(const std::string& host, int port, const std::string& prefix) + StatsdClient::StatsdClient(const std::string& host, + int port, + const std::string& prefix, + bool verbose) : _host(host) , _port(port) , _prefix(prefix) , _stop(false) + , _verbose(verbose) { _thread = std::thread([this] { setThreadName("Statsd"); @@ -119,9 +123,14 @@ namespace ix cleanup(key); std::stringstream ss; - ss << _prefix << "." << key << ":" << value << "|" << type << "\n"; + ss << _prefix << "." << key << ":" << value << "|" << type; - enqueue(ss.str()); + if (_verbose) + { + CoreLogger::info(ss.str()); + } + + enqueue(ss.str() + "\n"); return 0; } diff --git a/ixbots/ixbots/IXStatsdClient.h b/ixbots/ixbots/IXStatsdClient.h index 9e61bd18..9f0f77c9 100644 --- a/ixbots/ixbots/IXStatsdClient.h +++ b/ixbots/ixbots/IXStatsdClient.h @@ -20,7 +20,8 @@ namespace ix public: StatsdClient(const std::string& host = "127.0.0.1", int port = 8125, - const std::string& prefix = ""); + const std::string& prefix = "", + bool verbose = false); ~StatsdClient(); bool init(std::string& errMsg); @@ -52,6 +53,7 @@ namespace ix std::mutex _mutex; // for the queue std::deque _queue; + bool _verbose; }; } // end namespace ix diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index 2f99b622..5e30cdd2 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "9.6.6" +#define IX_WEBSOCKET_VERSION "9.6.7" diff --git a/ws/ws.cpp b/ws/ws.cpp index 24e47345..015c5ed6 100644 --- a/ws/ws.cpp +++ b/ws/ws.cpp @@ -563,7 +563,7 @@ int main(int argc, char** argv) } else { - ix::StatsdClient statsdClient(hostname, statsdPort, prefix); + ix::StatsdClient statsdClient(hostname, statsdPort, prefix, verbose); std::string errMsg; bool initialized = statsdClient.init(errMsg); @@ -581,7 +581,7 @@ int main(int argc, char** argv) } else if (app.got_subcommand("cobra_metrics_to_statsd")) { - ix::StatsdClient statsdClient(hostname, statsdPort, prefix); + ix::StatsdClient statsdClient(hostname, statsdPort, prefix, verbose); std::string errMsg; bool initialized = statsdClient.init(errMsg);