common/telemetry: Migrate namespace into the Common namespace

Migrates the Telemetry namespace into the Common namespace to make the
code consistent with the rest of our common code.
This commit is contained in:
Lioncash 2020-08-18 14:21:50 -04:00 committed by FearlessTobi
parent ddb4135dea
commit 10f440cb59
15 changed files with 47 additions and 43 deletions

View File

@ -382,7 +382,7 @@ int main(int argc, char** argv) {
break; // Expected case break; // Expected case
} }
system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "SDL"); system.TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "SDL");
if (use_multiplayer) { if (use_multiplayer) {
if (auto member = Network::GetRoomMember().lock()) { if (auto member = Network::GetRoomMember().lock()) {

View File

@ -52,7 +52,8 @@ void CompatDB::Submit() {
back(); back();
LOG_DEBUG(Frontend, "Compatibility Rating: {}", compatibility->checkedId()); LOG_DEBUG(Frontend, "Compatibility Rating: {}", compatibility->checkedId());
Core::System::GetInstance().TelemetrySession().AddField( Core::System::GetInstance().TelemetrySession().AddField(
Telemetry::FieldType::UserFeedback, "Compatibility", compatibility->checkedId()); Common::Telemetry::FieldType::UserFeedback, "Compatibility",
compatibility->checkedId());
button(NextButton)->setEnabled(false); button(NextButton)->setEnabled(false);
button(NextButton)->setText(tr("Submitting")); button(NextButton)->setText(tr("Submitting"));

View File

@ -1002,7 +1002,7 @@ bool GMainWindow::LoadROM(const QString& filename) {
game_path = filename; game_path = filename;
system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "Qt"); system.TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "Qt");
return true; return true;
} }

View File

@ -12,7 +12,7 @@
#include "common/x64/cpu_detect.h" #include "common/x64/cpu_detect.h"
#endif #endif
namespace Telemetry { namespace Common::Telemetry {
void FieldCollection::Accept(VisitorInterface& visitor) const { void FieldCollection::Accept(VisitorInterface& visitor) const {
for (const auto& field : fields) { for (const auto& field : fields) {
@ -88,4 +88,4 @@ void AppendOSInfo(FieldCollection& fc) {
#endif #endif
} }
} // namespace Telemetry } // namespace Common::Telemetry

View File

@ -10,7 +10,7 @@
#include <string> #include <string>
#include "common/common_types.h" #include "common/common_types.h"
namespace Telemetry { namespace Common::Telemetry {
/// Field type, used for grouping fields together in the final submitted telemetry log /// Field type, used for grouping fields together in the final submitted telemetry log
enum class FieldType : u8 { enum class FieldType : u8 {
@ -196,4 +196,4 @@ void AppendCPUInfo(FieldCollection& fc);
/// such as platform name, etc. /// such as platform name, etc.
void AppendOSInfo(FieldCollection& fc); void AppendOSInfo(FieldCollection& fc);
} // namespace Telemetry } // namespace Common::Telemetry

View File

@ -519,14 +519,13 @@ void System::RegisterImageInterface(std::shared_ptr<Frontend::ImageInterface> im
void System::Shutdown(bool is_deserializing) { void System::Shutdown(bool is_deserializing) {
// Log last frame performance stats // Log last frame performance stats
const auto perf_results = GetAndResetPerfStats(); const auto perf_results = GetAndResetPerfStats();
telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_EmulationSpeed", constexpr auto performance = Common::Telemetry::FieldType::Performance;
telemetry_session->AddField(performance, "Shutdown_EmulationSpeed",
perf_results.emulation_speed * 100.0); perf_results.emulation_speed * 100.0);
telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_Framerate", telemetry_session->AddField(performance, "Shutdown_Framerate", perf_results.game_fps);
perf_results.game_fps); telemetry_session->AddField(performance, "Shutdown_Frametime", perf_results.frametime * 1000.0);
telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_Frametime", telemetry_session->AddField(performance, "Mean_Frametime_MS", perf_stats->GetMeanFrametime());
perf_results.frametime * 1000.0);
telemetry_session->AddField(Telemetry::FieldType::Performance, "Mean_Frametime_MS",
perf_stats->GetMeanFrametime());
// Shutdown emulation session // Shutdown emulation session
VideoCore::Shutdown(); VideoCore::Shutdown();

View File

@ -230,8 +230,8 @@ void Module::APTInterface::GetSharedFont(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
// Log in telemetry if the game uses the shared font // Log in telemetry if the game uses the shared font
apt->system.TelemetrySession().AddField(Telemetry::FieldType::Session, "RequiresSharedFont", apt->system.TelemetrySession().AddField(Common::Telemetry::FieldType::Session,
true); "RequiresSharedFont", true);
if (!apt->shared_font_loaded) { if (!apt->shared_font_loaded) {
// On real 3DS, font loading happens on booting. However, we load it on demand to coordinate // On real 3DS, font loading happens on booting. However, we load it on demand to coordinate

View File

@ -199,7 +199,8 @@ ResultStatus AppLoader_NCCH::Load(std::shared_ptr<Kernel::Process>& process) {
} }
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();
system.TelemetrySession().AddField(Telemetry::FieldType::Session, "ProgramId", program_id); system.TelemetrySession().AddField(Common::Telemetry::FieldType::Session, "ProgramId",
program_id);
if (auto room_member = Network::GetRoomMember().lock()) { if (auto room_member = Network::GetRoomMember().lock()) {
Network::GameInfo game_info; Network::GameInfo game_info;

View File

@ -20,6 +20,8 @@
namespace Core { namespace Core {
namespace Telemetry = Common::Telemetry;
static u64 GenerateTelemetryId() { static u64 GenerateTelemetryId() {
u64 telemetry_id{}; u64 telemetry_id{};
CryptoPP::AutoSeededRandomPool rng; CryptoPP::AutoSeededRandomPool rng;

View File

@ -53,7 +53,7 @@ public:
* @param value Value for the field to add. * @param value Value for the field to add.
*/ */
template <typename T> template <typename T>
void AddField(Telemetry::FieldType type, const char* name, T value) { void AddField(Common::Telemetry::FieldType type, const char* name, T value) {
field_collection.AddField(type, name, std::move(value)); field_collection.AddField(type, name, std::move(value));
} }
@ -64,7 +64,8 @@ public:
bool SubmitTestcase(); bool SubmitTestcase();
private: private:
Telemetry::FieldCollection field_collection; ///< Tracks all added fields for the session /// Tracks all added fields for the session
Common::Telemetry::FieldCollection field_collection;
}; };
/** /**

View File

@ -1532,8 +1532,8 @@ vec4 secondary_fragment_color = vec4(0.0);
// Blend the fog // Blend the fog
out += "last_tex_env_out.rgb = mix(fog_color.rgb, last_tex_env_out.rgb, fog_factor);\n"; out += "last_tex_env_out.rgb = mix(fog_color.rgb, last_tex_env_out.rgb, fog_factor);\n";
} else if (state.fog_mode == TexturingRegs::FogMode::Gas) { } else if (state.fog_mode == TexturingRegs::FogMode::Gas) {
Core::System::GetInstance().TelemetrySession().AddField(Telemetry::FieldType::Session, Core::System::GetInstance().TelemetrySession().AddField(
"VideoCore_Pica_UseGasMode", true); Common::Telemetry::FieldType::Session, "VideoCore_Pica_UseGasMode", true);
LOG_CRITICAL(Render_OpenGL, "Unimplemented gas mode"); LOG_CRITICAL(Render_OpenGL, "Unimplemented gas mode");
out += "discard; }"; out += "discard; }";
return {std::move(out)}; return {std::move(out)};

View File

@ -91,7 +91,7 @@ inline GLenum WrapMode(Pica::TexturingRegs::TextureConfig::WrapMode mode) {
if (index > 3) { if (index > 3) {
Core::System::GetInstance().TelemetrySession().AddField( Core::System::GetInstance().TelemetrySession().AddField(
Telemetry::FieldType::Session, "VideoCore_Pica_UnsupportedTextureWrapMode", Common::Telemetry::FieldType::Session, "VideoCore_Pica_UnsupportedTextureWrapMode",
static_cast<u32>(index)); static_cast<u32>(index));
LOG_WARNING(Render_OpenGL, "Using texture wrap mode {}", index); LOG_WARNING(Render_OpenGL, "Using texture wrap mode {}", index);
} }

View File

@ -1210,12 +1210,10 @@ VideoCore::ResultStatus RendererOpenGL::Init() {
LOG_INFO(Render_OpenGL, "GL_RENDERER: {}", gpu_model); LOG_INFO(Render_OpenGL, "GL_RENDERER: {}", gpu_model);
auto& telemetry_session = Core::System::GetInstance().TelemetrySession(); auto& telemetry_session = Core::System::GetInstance().TelemetrySession();
telemetry_session.AddField(Telemetry::FieldType::UserSystem, "GPU_Vendor", constexpr auto user_system = Common::Telemetry::FieldType::UserSystem;
std::string(gpu_vendor)); telemetry_session.AddField(user_system, "GPU_Vendor", std::string(gpu_vendor));
telemetry_session.AddField(Telemetry::FieldType::UserSystem, "GPU_Model", telemetry_session.AddField(user_system, "GPU_Model", std::string(gpu_model));
std::string(gpu_model)); telemetry_session.AddField(user_system, "GPU_OpenGL_Version", std::string(gl_version));
telemetry_session.AddField(Telemetry::FieldType::UserSystem, "GPU_OpenGL_Version",
std::string(gl_version));
if (!strcmp(gpu_vendor, "GDI Generic")) { if (!strcmp(gpu_vendor, "GDI Generic")) {
return VideoCore::ResultStatus::ErrorGenericDrivers; return VideoCore::ResultStatus::ErrorGenericDrivers;

View File

@ -10,6 +10,8 @@
namespace WebService { namespace WebService {
namespace Telemetry = Common::Telemetry;
struct TelemetryJson::Impl { struct TelemetryJson::Impl {
Impl(std::string host, std::string username, std::string token) Impl(std::string host, std::string username, std::string token)
: host{std::move(host)}, username{std::move(username)}, token{std::move(token)} {} : host{std::move(host)}, username{std::move(username)}, token{std::move(token)} {}

View File

@ -15,25 +15,25 @@ namespace WebService {
* Implementation of VisitorInterface that serialized telemetry into JSON, and submits it to the * Implementation of VisitorInterface that serialized telemetry into JSON, and submits it to the
* Citra web service * Citra web service
*/ */
class TelemetryJson : public Telemetry::VisitorInterface { class TelemetryJson : public Common::Telemetry::VisitorInterface {
public: public:
TelemetryJson(std::string host, std::string username, std::string token); TelemetryJson(std::string host, std::string username, std::string token);
~TelemetryJson() override; ~TelemetryJson() override;
void Visit(const Telemetry::Field<bool>& field) override; void Visit(const Common::Telemetry::Field<bool>& field) override;
void Visit(const Telemetry::Field<double>& field) override; void Visit(const Common::Telemetry::Field<double>& field) override;
void Visit(const Telemetry::Field<float>& field) override; void Visit(const Common::Telemetry::Field<float>& field) override;
void Visit(const Telemetry::Field<u8>& field) override; void Visit(const Common::Telemetry::Field<u8>& field) override;
void Visit(const Telemetry::Field<u16>& field) override; void Visit(const Common::Telemetry::Field<u16>& field) override;
void Visit(const Telemetry::Field<u32>& field) override; void Visit(const Common::Telemetry::Field<u32>& field) override;
void Visit(const Telemetry::Field<u64>& field) override; void Visit(const Common::Telemetry::Field<u64>& field) override;
void Visit(const Telemetry::Field<s8>& field) override; void Visit(const Common::Telemetry::Field<s8>& field) override;
void Visit(const Telemetry::Field<s16>& field) override; void Visit(const Common::Telemetry::Field<s16>& field) override;
void Visit(const Telemetry::Field<s32>& field) override; void Visit(const Common::Telemetry::Field<s32>& field) override;
void Visit(const Telemetry::Field<s64>& field) override; void Visit(const Common::Telemetry::Field<s64>& field) override;
void Visit(const Telemetry::Field<std::string>& field) override; void Visit(const Common::Telemetry::Field<std::string>& field) override;
void Visit(const Telemetry::Field<const char*>& field) override; void Visit(const Common::Telemetry::Field<const char*>& field) override;
void Visit(const Telemetry::Field<std::chrono::microseconds>& field) override; void Visit(const Common::Telemetry::Field<std::chrono::microseconds>& field) override;
void Complete() override; void Complete() override;
bool SubmitTestcase() override; bool SubmitTestcase() override;