(cobra metrics to statsd bot) send info about net requests

This commit is contained in:
Benjamin Sergeant 2020-06-18 11:25:48 -07:00
parent 56db55caca
commit 9bb3643fc7
4 changed files with 61 additions and 5 deletions

View File

@ -1,6 +1,10 @@
# Changelog
All changes to this project will be documented in this file.
## [9.7.8] - 2020-06-18
(cobra metrics to statsd bot) send info about net requests
## [9.7.7] - 2020-06-17
(cobra client and bots) add batch_size subscription option for retrieving multiple messages at once

View File

@ -115,9 +115,15 @@ namespace ix
std::atomic<bool>& /*throttled*/,
std::atomic<bool>& /*fatalCobraError*/,
std::atomic<uint64_t>& sentCount) -> void {
if (msg["device"].isNull() || msg["id"].isNull())
if (msg["device"].isNull())
{
CoreLogger::info("no device or id entry, skipping event");
CoreLogger::info("no device entry, skipping event");
return;
}
if (msg["id"].isNull())
{
CoreLogger::info("no id entry, skipping event");
return;
}

View File

@ -33,6 +33,42 @@ namespace
namespace ix
{
bool processNetRequestMetricsEvent(const Json::Value& msg,
StatsdClient& statsdClient)
{
auto durationMs = msg["data"]["duration_ms"].asUInt64();
auto size = msg["data"]["size"].asUInt64();
auto controller = msg["data"]["params"]["_controller"].asString();
auto action = msg["data"]["params"]["_action"].asString();
auto game = msg["device"]["game"].asString();
auto status = msg["data"]["status"].asInt();
auto osName = msg["device"]["os_name"].asString();
bool valid = true;
valid |= controller == "game_session" && action == "start";
valid |= controller == "asset" && action == "manifest";
valid |= controller == "iso_login" && action == "post_start_session";
if (!valid) return false;
// We only worry about successful requests
if (status != 200) return false;
std::stringstream ss;
ss << msg["id"].asString() << "."
<< "v1."
<< game << "."
<< osName << "."
<< controller << "."
<< action;
std::string id = ss.str();
statsdClient.gauge(id + ".duration_ms", durationMs);
statsdClient.gauge(id + ".size", size);
return true;
}
bool processPerfMetricsEvent(const Json::Value& msg,
StatsdClient& statsdClient)
{
@ -151,9 +187,15 @@ namespace ix
std::atomic<bool>& /*throttled*/,
std::atomic<bool>& /*fatalCobraError*/,
std::atomic<uint64_t>& sentCount) -> void {
if (msg["device"].isNull() || msg["id"].isNull())
if (msg["device"].isNull())
{
CoreLogger::info("no device or id entry, skipping event");
CoreLogger::info("no device entry, skipping event");
return;
}
if (msg["id"].isNull())
{
CoreLogger::info("no id entry, skipping event");
return;
}
@ -170,6 +212,10 @@ namespace ix
success = processPerfMetricsEvent(msg, statsdClient);
success |= processPerfMetricsEventSlowFrames(msg, statsdClient, deviceIdCounters, sentCount);
}
else if (msg["id"].asString() == "engine_net_request_id")
{
success = processNetRequestMetricsEvent(msg, statsdClient);
}
if (success) sentCount++;
});

View File

@ -6,4 +6,4 @@
#pragma once
#define IX_WEBSOCKET_VERSION "9.7.7"
#define IX_WEBSOCKET_VERSION "9.7.8"