[vcpkg-metrics] Adjust reporting of build times
MODIFY
include/vcpkg/metrics.h
include/vcpkg/metrics.h
@@ -14,6 +14,7 @@ namespace vcpkg::Metrics
static void init_user_information(std::string& user_id, std::string& first_use_time);
void track_metric(const std::string& name, double value);
+ void track_buildtime(const std::string& name, double value);
void track_property(const std::string& name, const std::string& value);
void upload(const std::string& payload);

MODIFY
src/vcpkg/build.cpp
src/vcpkg/build.cpp
@@ -339,7 +339,8 @@ namespace vcpkg::Build
{
auto locked_metrics = Metrics::g_metrics.lock();
- locked_metrics->track_metric("buildtimeus-" + spec_string, buildtimeus);
+ locked_metrics->track_buildtime(spec.to_string() + ":[" + Strings::join(",", config.feature_list) + "]",
+ buildtimeus);
if (return_code != 0)
{
locked_metrics->track_property("error", "build failed");

MODIFY
src/vcpkg/metrics.cpp
src/vcpkg/metrics.cpp
@@ -150,6 +150,9 @@ namespace vcpkg::Metrics
std::string properties;
std::string measurements;
+ std::vector<std::string> buildtime_names;
+ std::vector<std::string> buildtime_times;
+
void track_property(const std::string& name, const std::string& value)
{
if (properties.size() != 0) properties.push_back(',');
@@ -166,8 +169,23 @@ namespace vcpkg::Metrics
measurements.append(std::to_string(value));
}
+ void track_buildtime(const std::string& name, double value)
+ {
+ buildtime_names.push_back(name);
+ buildtime_times.push_back(std::to_string(value));
+ }
+
std::string format_event_data_template() const
{
+ auto props_plus_buildtimes = properties;
+ if (buildtime_names.size() > 0)
+ {
+ if (props_plus_buildtimes.size() > 0) props_plus_buildtimes.push_back(',');
+ props_plus_buildtimes.append(Strings::format(R"("buildnames": [%s], "buildtimes": [%s])",
+ Strings::join(",", buildtime_names, to_json_string),
+ Strings::join(",", buildtime_times)));
+ }
+
const std::string& session_id = get_session_id();
return Strings::format(R"([{
"ver": 1,
@@ -199,7 +217,7 @@ namespace vcpkg::Metrics
session_id,
user_id,
user_timestamp,
- properties,
+ props_plus_buildtimes,
measurements);
}
};
@@ -274,6 +292,11 @@ namespace vcpkg::Metrics
void Metrics::track_metric(const std::string& name, double value) { g_metricmessage.track_metric(name, value); }
+ void Metrics::track_buildtime(const std::string& name, double value)
+ {
+ g_metricmessage.track_buildtime(name, value);
+ }
+
void Metrics::track_property(const std::string& name, const std::string& value)
{
g_metricmessage.track_property(name, value);

[vcpkg-metrics] Adjust reporting of build times