aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/metrics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/src/metrics.cpp')
-rw-r--r--toolsrc/src/metrics.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/toolsrc/src/metrics.cpp b/toolsrc/src/metrics.cpp
index 7992f3e51..6263c0fcb 100644
--- a/toolsrc/src/metrics.cpp
+++ b/toolsrc/src/metrics.cpp
@@ -8,6 +8,8 @@
namespace vcpkg::Metrics
{
+ Util::LockGuarded<Metrics> g_metrics;
+
static std::string get_current_date_time()
{
struct tm newtime;
@@ -223,25 +225,25 @@ namespace vcpkg::Metrics
return hkcu_sqmclient.value_or(L"{}");
}
- void set_user_information(const std::string& user_id, const std::string& first_use_time)
+ void Metrics::set_user_information(const std::string& user_id, const std::string& first_use_time)
{
g_metricmessage.user_id = user_id;
g_metricmessage.user_timestamp = first_use_time;
}
- void init_user_information(std::string& user_id, std::string& first_use_time)
+ void Metrics::init_user_information(std::string& user_id, std::string& first_use_time)
{
user_id = generate_random_UUID();
first_use_time = get_current_date_time();
}
- void set_send_metrics(bool should_send_metrics) { g_should_send_metrics = should_send_metrics; }
+ void Metrics::set_send_metrics(bool should_send_metrics) { g_should_send_metrics = should_send_metrics; }
- void set_print_metrics(bool should_print_metrics) { g_should_print_metrics = should_print_metrics; }
+ void Metrics::set_print_metrics(bool should_print_metrics) { g_should_print_metrics = should_print_metrics; }
- void track_metric(const std::string& name, double value) { g_metricmessage.TrackMetric(name, value); }
+ void Metrics::track_metric(const std::string& name, double value) { g_metricmessage.TrackMetric(name, value); }
- void track_property(const std::string& name, const std::wstring& value)
+ void Metrics::track_property(const std::string& name, const std::wstring& value)
{
// Note: this is not valid UTF-16 -> UTF-8, it just yields a close enough approximation for our purposes.
std::string converted_value;
@@ -252,12 +254,12 @@ namespace vcpkg::Metrics
g_metricmessage.TrackProperty(name, converted_value);
}
- void track_property(const std::string& name, const std::string& value)
+ void Metrics::track_property(const std::string& name, const std::string& value)
{
g_metricmessage.TrackProperty(name, value);
}
- void upload(const std::string& payload)
+ void Metrics::upload(const std::string& payload)
{
HINTERNET hSession = nullptr, hConnect = nullptr, hRequest = nullptr;
BOOL bResults = FALSE;
@@ -349,7 +351,7 @@ namespace vcpkg::Metrics
return fs::path(buf, buf + bytes);
}
- void flush()
+ void Metrics::flush()
{
std::string payload = g_metricmessage.format_event_data_template();
if (g_should_print_metrics) std::cerr << payload << "\n";