[vcpkg] Add metrics for binarycaching feature
MODIFY
src/vcpkg/binarycaching.cpp
src/vcpkg/binarycaching.cpp
#include <vcpkg/binarycaching.private.h>
#include <vcpkg/build.h>
#include <vcpkg/dependencies.h>
+#include <vcpkg/metrics.h>
#include <vcpkg/tools.h>
using namespace vcpkg;
@@ -667,6 +668,7 @@ namespace
auto maybe_cachepath = System::get_environment_variable("VCPKG_DEFAULT_BINARY_CACHE");
if (auto p_str = maybe_cachepath.get())
{
+ Metrics::g_metrics.lock()->track_property("VCPKG_DEFAULT_BINARY_CACHE", "defined");
const auto path = fs::u8path(*p_str);
const auto status = fs::stdfs::status(path);
if (!fs::stdfs::exists(status))
@@ -915,6 +917,12 @@ namespace
ExpectedS<std::unique_ptr<IBinaryProvider>> vcpkg::create_binary_provider_from_configs_pure(
const std::string& env_string, View<std::string> args)
{
+ {
+ auto metrics = Metrics::g_metrics.lock();
+ if (!env_string.empty()) metrics->track_property("VCPKG_BINARY_SOURCES", "defined");
+ if (args.size() != 0) metrics->track_property("binarycaching-source", "defined");
+ }
+
State s;
BinaryConfigParser default_parser("default,readwrite", "<defaults>", &s);
@@ -930,17 +938,22 @@ ExpectedS<std::unique_ptr<IBinaryProvider>> vcpkg::create_binary_provider_from_c
if (auto err = arg_parser.get_error()) return err->format();
}
+ if (s.m_cleared) Metrics::g_metrics.lock()->track_property("binarycaching-clear", "defined");
+
std::vector<std::unique_ptr<IBinaryProvider>> providers;
if (!s.archives_to_read.empty() || !s.archives_to_write.empty())
providers.push_back(
std::make_unique<ArchivesBinaryProvider>(std::move(s.archives_to_read), std::move(s.archives_to_write)));
if (!s.sources_to_read.empty() || !s.sources_to_write.empty() || !s.configs_to_read.empty() ||
!s.configs_to_write.empty())
+ {
+ Metrics::g_metrics.lock()->track_property("binarycaching-nuget", "defined");
providers.push_back(std::make_unique<NugetBinaryProvider>(std::move(s.sources_to_read),
std::move(s.sources_to_write),
std::move(s.configs_to_read),
std::move(s.configs_to_write),
s.interactive));
+ }
return {std::make_unique<MergeBinaryProviders>(std::move(providers))};
}
@@ -978,6 +991,7 @@ details::NuGetRepoInfo details::get_nuget_repo_info_from_env()
auto vcpkg_nuget_repository = System::get_environment_variable("VCPKG_NUGET_REPOSITORY");
if (auto p = vcpkg_nuget_repository.get())
{
+ Metrics::g_metrics.lock()->track_property("VCPKG_NUGET_REPOSITORY", "defined");
return {std::move(*p)};
}
auto gh_repo = System::get_environment_variable("GITHUB_REPOSITORY").value_or("");
@@ -985,6 +999,8 @@ details::NuGetRepoInfo details::get_nuget_repo_info_from_env()
auto gh_server = System::get_environment_variable("GITHUB_SERVER_URL").value_or("");
if (gh_server.empty()) return {};
+ Metrics::g_metrics.lock()->track_property("GITHUB_REPOSITORY", "defined");
+
return {Strings::concat(gh_server, '/', gh_repo, ".git"),
System::get_environment_variable("GITHUB_REF").value_or(""),
System::get_environment_variable("GITHUB_SHA").value_or("")};

MODIFY
src/vcpkg/commands.setinstalled.cpp
src/vcpkg/commands.setinstalled.cpp
#include <vcpkg/help.h>
#include <vcpkg/input.h>
#include <vcpkg/install.h>
+#include <vcpkg/metrics.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/remove.h>
#include <vcpkg/vcpkgcmdarguments.h>
@@ -141,6 +142,7 @@ namespace vcpkg::Commands::SetInstalled
auto it_pkgsconfig = options.settings.find(OPTION_WRITE_PACKAGES_CONFIG);
if (it_pkgsconfig != options.settings.end())
{
+ Metrics::g_metrics.lock()->track_property("x-write-nuget-packages-config", "defined");
pkgsconfig = it_pkgsconfig->second;
}

MODIFY
src/vcpkg/install.cpp
src/vcpkg/install.cpp
@@ -786,6 +786,7 @@ namespace vcpkg::Install
auto it_pkgsconfig = options.settings.find(OPTION_WRITE_PACKAGES_CONFIG);
if (it_pkgsconfig != options.settings.end())
{
+ Metrics::g_metrics.lock()->track_property("x-write-nuget-packages-config", "defined");
pkgsconfig = fs::u8path(it_pkgsconfig->second);
}
auto manifest_path = paths.get_manifest_path().value_or_exit(VCPKG_LINE_INFO);
@@ -924,6 +925,7 @@ namespace vcpkg::Install
auto it_pkgsconfig = options.settings.find(OPTION_WRITE_PACKAGES_CONFIG);
if (it_pkgsconfig != options.settings.end())
{
+ Metrics::g_metrics.lock()->track_property("x-write-nuget-packages-config", "defined");
Build::compute_all_abis(paths, action_plan, var_provider, status_db);
auto pkgsconfig_path = Files::combine(paths.original_cwd, fs::u8path(it_pkgsconfig->second));

[vcpkg] Add metrics for binarycaching feature (#13486)

Co-authored-by: Robert Schumacher <roschuma@microsoft.com>