summaryrefslogtreecommitdiff
path: root/src/core/telemetry_session.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/telemetry_session.cpp')
-rw-r--r--src/core/telemetry_session.cpp18
1 files changed, 18 insertions, 0 deletions
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 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cstring>
6
5#include "common/scm_rev.h" 7#include "common/scm_rev.h"
6#include "core/telemetry_session.h" 8#include "core/telemetry_session.h"
7 9
@@ -10,9 +12,25 @@ namespace Core {
10TelemetrySession::TelemetrySession() { 12TelemetrySession::TelemetrySession() {
11 // TODO(bunnei): Replace with a backend that logs to our web service 13 // TODO(bunnei): Replace with a backend that logs to our web service
12 backend = std::make_unique<Telemetry::NullVisitor>(); 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);
13} 26}
14 27
15TelemetrySession::~TelemetrySession() { 28TelemetrySession::~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
16 // Complete the session, submitting to web service if necessary 34 // Complete the session, submitting to web service if necessary
17 // This is just a placeholder to wrap up the session once the core completes and this is 35 // This is just a placeholder to wrap up the session once the core completes and this is
18 // destroyed. This will be moved elsewhere once we are actually doing real I/O with the service. 36 // destroyed. This will be moved elsewhere once we are actually doing real I/O with the service.