From 120b00fb1aee96aec42b1647ece98dcc3e192139 Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 2 May 2017 00:10:04 -0400 Subject: telemetry: Log a few simple data fields throughout core. --- src/core/telemetry_session.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/core/telemetry_session.cpp') diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index ec8f7d95e..ddc8b262e 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include + #include "common/scm_rev.h" #include "core/telemetry_session.h" @@ -10,9 +12,25 @@ namespace Core { TelemetrySession::TelemetrySession() { // TODO(bunnei): Replace with a backend that logs to our web service backend = std::make_unique(); + + // Log one-time session start information + const auto duration{std::chrono::steady_clock::now().time_since_epoch()}; + const auto start_time{std::chrono::duration_cast(duration).count()}; + AddField(Telemetry::FieldType::Session, "StartTime", start_time); + + // Log one-time application information + const bool is_git_dirty{std::strstr(Common::g_scm_desc, "dirty") != nullptr}; + AddField(Telemetry::FieldType::App, "GitIsDirty", is_git_dirty); + AddField(Telemetry::FieldType::App, "GitBranch", Common::g_scm_branch); + AddField(Telemetry::FieldType::App, "GitRevision", Common::g_scm_rev); } TelemetrySession::~TelemetrySession() { + // Log one-time session end information + const auto duration{std::chrono::steady_clock::now().time_since_epoch()}; + const auto end_time{std::chrono::duration_cast(duration).count()}; + AddField(Telemetry::FieldType::Session, "EndTime", end_time); + // Complete the session, submitting to web service if necessary // This is just a placeholder to wrap up the session once the core completes and this is // destroyed. This will be moved elsewhere once we are actually doing real I/O with the service. -- cgit v1.2.3