diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2018-02-20 18:02:00 -0800 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2018-02-20 18:02:09 -0800 |
| commit | adb0930bc54dbff26acf131971199c3f57bdd0fb (patch) | |
| tree | 91b7c43a268e37bdce2280a45ce4177ce4ad4cdd | |
| parent | 85f2b92958c4f056ef171ebea275450dcfd3efa4 (diff) | |
| download | vcpkg-adb0930bc54dbff26acf131971199c3f57bdd0fb.tar.gz vcpkg-adb0930bc54dbff26acf131971199c3f57bdd0fb.zip | |
[vcpkg-metrics] Adjust reporting of build times
| -rw-r--r-- | toolsrc/include/vcpkg/metrics.h | 1 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/build.cpp | 3 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/metrics.cpp | 25 |
3 files changed, 27 insertions, 2 deletions
diff --git a/toolsrc/include/vcpkg/metrics.h b/toolsrc/include/vcpkg/metrics.h index ee6f8eb51..cb27ba58d 100644 --- a/toolsrc/include/vcpkg/metrics.h +++ b/toolsrc/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); diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index cc376c773..7d249bd0c 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/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"); diff --git a/toolsrc/src/vcpkg/metrics.cpp b/toolsrc/src/vcpkg/metrics.cpp index cdb21d260..1f9ddde38 100644 --- a/toolsrc/src/vcpkg/metrics.cpp +++ b/toolsrc/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); |
