diff options
| author | 2017-05-24 19:33:54 -0400 | |
|---|---|---|
| committer | 2017-05-24 19:33:54 -0400 | |
| commit | 634229ff45f0780567d00114289a3c3ca7b3f424 (patch) | |
| tree | 2278bd436cd8887c0f35a6ef8fcb5fcb68adaae2 /src/core/telemetry_session.cpp | |
| parent | Merge pull request #2692 from Subv/vfp_ftz (diff) | |
| parent | telemetry: Log a few simple data fields throughout core. (diff) | |
| download | yuzu-634229ff45f0780567d00114289a3c3ca7b3f424.tar.gz yuzu-634229ff45f0780567d00114289a3c3ca7b3f424.tar.xz yuzu-634229ff45f0780567d00114289a3c3ca7b3f424.zip | |
Merge pull request #2683 from bunnei/telemetry-framework
Telemetry framework Part 1
Diffstat (limited to 'src/core/telemetry_session.cpp')
| -rw-r--r-- | src/core/telemetry_session.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp new file mode 100644 index 000000000..ddc8b262e --- /dev/null +++ b/src/core/telemetry_session.cpp | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | // Copyright 2017 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <cstring> | ||
| 6 | |||
| 7 | #include "common/scm_rev.h" | ||
| 8 | #include "core/telemetry_session.h" | ||
| 9 | |||
| 10 | namespace Core { | ||
| 11 | |||
| 12 | TelemetrySession::TelemetrySession() { | ||
| 13 | // TODO(bunnei): Replace with a backend that logs to our web service | ||
| 14 | backend = std::make_unique<Telemetry::NullVisitor>(); | ||
| 15 | |||
| 16 | // Log one-time session start information | ||
| 17 | const auto duration{std::chrono::steady_clock::now().time_since_epoch()}; | ||
| 18 | const auto start_time{std::chrono::duration_cast<std::chrono::microseconds>(duration).count()}; | ||
| 19 | AddField(Telemetry::FieldType::Session, "StartTime", start_time); | ||
| 20 | |||
| 21 | // Log one-time application information | ||
| 22 | const bool is_git_dirty{std::strstr(Common::g_scm_desc, "dirty") != nullptr}; | ||
| 23 | AddField(Telemetry::FieldType::App, "GitIsDirty", is_git_dirty); | ||
| 24 | AddField(Telemetry::FieldType::App, "GitBranch", Common::g_scm_branch); | ||
| 25 | AddField(Telemetry::FieldType::App, "GitRevision", Common::g_scm_rev); | ||
| 26 | } | ||
| 27 | |||
| 28 | TelemetrySession::~TelemetrySession() { | ||
| 29 | // Log one-time session end information | ||
| 30 | const auto duration{std::chrono::steady_clock::now().time_since_epoch()}; | ||
| 31 | const auto end_time{std::chrono::duration_cast<std::chrono::microseconds>(duration).count()}; | ||
| 32 | AddField(Telemetry::FieldType::Session, "EndTime", end_time); | ||
| 33 | |||
| 34 | // Complete the session, submitting to web service if necessary | ||
| 35 | // This is just a placeholder to wrap up the session once the core completes and this is | ||
| 36 | // destroyed. This will be moved elsewhere once we are actually doing real I/O with the service. | ||
| 37 | field_collection.Accept(*backend); | ||
| 38 | backend->Complete(); | ||
| 39 | backend = nullptr; | ||
| 40 | } | ||
| 41 | |||
| 42 | } // namespace Core | ||