mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-24 11:37:12 +01:00
Rename Metrics:: function to all_lower
This commit is contained in:
parent
c86dbc960e
commit
830a4d97d4
@ -4,17 +4,17 @@
|
|||||||
|
|
||||||
namespace vcpkg::Metrics
|
namespace vcpkg::Metrics
|
||||||
{
|
{
|
||||||
void SetSendMetrics(bool should_send_metrics);
|
void set_send_metrics(bool should_send_metrics);
|
||||||
void SetPrintMetrics(bool should_print_metrics);
|
void set_print_metrics(bool should_print_metrics);
|
||||||
void SetUserInformation(const std::string& user_id, const std::string& first_use_time);
|
void set_user_information(const std::string& user_id, const std::string& first_use_time);
|
||||||
void InitUserInformation(std::string& user_id, std::string& first_use_time);
|
void init_user_information(std::string& user_id, std::string& first_use_time);
|
||||||
|
|
||||||
void TrackMetric(const std::string& name, double value);
|
void track_metric(const std::string& name, double value);
|
||||||
void TrackProperty(const std::string& name, const std::string& value);
|
void track_property(const std::string& name, const std::string& value);
|
||||||
void TrackProperty(const std::string& name, const std::wstring& value);
|
void track_property(const std::string& name, const std::wstring& value);
|
||||||
bool GetCompiledMetricsEnabled();
|
bool get_compiled_metrics_enabled();
|
||||||
std::wstring GetSQMUser();
|
std::wstring get_SQM_user();
|
||||||
|
|
||||||
void Upload(const std::string& payload);
|
void upload(const std::string& payload);
|
||||||
void Flush();
|
void flush();
|
||||||
}
|
}
|
||||||
|
@ -68,12 +68,12 @@ namespace vcpkg::Commands::Build
|
|||||||
|
|
||||||
int return_code = System::cmd_execute_clean(command);
|
int return_code = System::cmd_execute_clean(command);
|
||||||
auto buildtimeus = timer.microseconds();
|
auto buildtimeus = timer.microseconds();
|
||||||
Metrics::TrackMetric("buildtimeus-" + spec.toString(), buildtimeus);
|
Metrics::track_metric("buildtimeus-" + spec.toString(), buildtimeus);
|
||||||
|
|
||||||
if (return_code != 0)
|
if (return_code != 0)
|
||||||
{
|
{
|
||||||
Metrics::TrackProperty("error", "build failed");
|
Metrics::track_property("error", "build failed");
|
||||||
Metrics::TrackProperty("build_error", spec.toString());
|
Metrics::track_property("build_error", spec.toString());
|
||||||
return BuildResult::BUILD_FAILED;
|
return BuildResult::BUILD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ namespace vcpkg::Commands::Install
|
|||||||
specs_string.push_back(',');
|
specs_string.push_back(',');
|
||||||
specs_string.append(install_plan[i].spec.toString());
|
specs_string.append(install_plan[i].spec.toString());
|
||||||
}
|
}
|
||||||
Metrics::TrackProperty("installplan", specs_string);
|
Metrics::track_property("installplan", specs_string);
|
||||||
|
|
||||||
// execute the plan
|
// execute the plan
|
||||||
for (const package_spec_with_install_plan& action : install_plan)
|
for (const package_spec_with_install_plan& action : install_plan)
|
||||||
|
@ -19,7 +19,7 @@ namespace vcpkg::Commands::Version
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
+ std::string("-debug")
|
+ std::string("-debug")
|
||||||
#endif
|
#endif
|
||||||
+ std::string(Metrics::GetCompiledMetricsEnabled() ? "" : "-external");
|
+ std::string(Metrics::get_compiled_metrics_enabled() ? "" : "-external");
|
||||||
return s_version;
|
return s_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,45 +220,45 @@ true
|
|||||||
;
|
;
|
||||||
static bool g_should_print_metrics = false;
|
static bool g_should_print_metrics = false;
|
||||||
|
|
||||||
bool GetCompiledMetricsEnabled()
|
bool get_compiled_metrics_enabled()
|
||||||
{
|
{
|
||||||
return DISABLE_METRICS == 0;
|
return DISABLE_METRICS == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring GetSQMUser()
|
std::wstring get_SQM_user()
|
||||||
{
|
{
|
||||||
auto hkcu_sqmclient = System::get_registry_string(HKEY_CURRENT_USER, LR"(Software\Microsoft\SQMClient)", L"UserId");
|
auto hkcu_sqmclient = System::get_registry_string(HKEY_CURRENT_USER, LR"(Software\Microsoft\SQMClient)", L"UserId");
|
||||||
return hkcu_sqmclient.value_or(L"{}");
|
return hkcu_sqmclient.value_or(L"{}");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUserInformation(const std::string& user_id, const std::string& first_use_time)
|
void set_user_information(const std::string& user_id, const std::string& first_use_time)
|
||||||
{
|
{
|
||||||
g_metricmessage.user_id = user_id;
|
g_metricmessage.user_id = user_id;
|
||||||
g_metricmessage.user_timestamp = first_use_time;
|
g_metricmessage.user_timestamp = first_use_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitUserInformation(std::string& user_id, std::string& first_use_time)
|
void init_user_information(std::string& user_id, std::string& first_use_time)
|
||||||
{
|
{
|
||||||
user_id = GenerateRandomUUID();
|
user_id = GenerateRandomUUID();
|
||||||
first_use_time = GetCurrentDateTime();
|
first_use_time = GetCurrentDateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetSendMetrics(bool should_send_metrics)
|
void set_send_metrics(bool should_send_metrics)
|
||||||
{
|
{
|
||||||
g_should_send_metrics = should_send_metrics;
|
g_should_send_metrics = should_send_metrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPrintMetrics(bool should_print_metrics)
|
void set_print_metrics(bool should_print_metrics)
|
||||||
{
|
{
|
||||||
g_should_print_metrics = should_print_metrics;
|
g_should_print_metrics = should_print_metrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackMetric(const std::string& name, double value)
|
void track_metric(const std::string& name, double value)
|
||||||
{
|
{
|
||||||
g_metricmessage.TrackMetric(name, value);
|
g_metricmessage.TrackMetric(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackProperty(const std::string& name, const std::wstring& value)
|
void 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.
|
// Note: this is not valid UTF-16 -> UTF-8, it just yields a close enough approximation for our purposes.
|
||||||
std::string converted_value;
|
std::string converted_value;
|
||||||
@ -274,12 +274,12 @@ true
|
|||||||
g_metricmessage.TrackProperty(name, converted_value);
|
g_metricmessage.TrackProperty(name, converted_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackProperty(const std::string& name, const std::string& value)
|
void track_property(const std::string& name, const std::string& value)
|
||||||
{
|
{
|
||||||
g_metricmessage.TrackProperty(name, value);
|
g_metricmessage.TrackProperty(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Upload(const std::string& payload)
|
void upload(const std::string& payload)
|
||||||
{
|
{
|
||||||
HINTERNET hSession = nullptr, hConnect = nullptr, hRequest = nullptr;
|
HINTERNET hSession = nullptr, hConnect = nullptr, hRequest = nullptr;
|
||||||
BOOL bResults = FALSE;
|
BOOL bResults = FALSE;
|
||||||
@ -371,7 +371,7 @@ true
|
|||||||
return fs::path(buf, buf + bytes);
|
return fs::path(buf, buf + bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flush()
|
void flush()
|
||||||
{
|
{
|
||||||
std::string payload = g_metricmessage.format_event_data_template();
|
std::string payload = g_metricmessage.format_event_data_template();
|
||||||
if (g_should_print_metrics)
|
if (g_should_print_metrics)
|
||||||
@ -379,7 +379,7 @@ true
|
|||||||
if (!g_should_send_metrics)
|
if (!g_should_send_metrics)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Upload(payload);
|
// upload(payload);
|
||||||
|
|
||||||
wchar_t temp_folder[MAX_PATH];
|
wchar_t temp_folder[MAX_PATH];
|
||||||
GetTempPathW(MAX_PATH, temp_folder);
|
GetTempPathW(MAX_PATH, temp_folder);
|
||||||
|
@ -26,7 +26,7 @@ void invalid_command(const std::string& cmd)
|
|||||||
|
|
||||||
static void inner(const vcpkg_cmd_arguments& args)
|
static void inner(const vcpkg_cmd_arguments& args)
|
||||||
{
|
{
|
||||||
Metrics::TrackProperty("command", args.command);
|
Metrics::track_property("command", args.command);
|
||||||
if (args.command.empty())
|
if (args.command.empty())
|
||||||
{
|
{
|
||||||
Commands::Help::print_usage();
|
Commands::Help::print_usage();
|
||||||
@ -130,7 +130,7 @@ static void loadConfig()
|
|||||||
auto user_time = keys["User-Since"];
|
auto user_time = keys["User-Since"];
|
||||||
if (!user_id.empty() && !user_time.empty())
|
if (!user_id.empty() && !user_time.empty())
|
||||||
{
|
{
|
||||||
Metrics::SetUserInformation(user_id, user_time);
|
Metrics::set_user_information(user_id, user_time);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,8 +139,8 @@ static void loadConfig()
|
|||||||
|
|
||||||
// config file not found, could not be read, or invalid
|
// config file not found, could not be read, or invalid
|
||||||
std::string user_id, user_time;
|
std::string user_id, user_time;
|
||||||
Metrics::InitUserInformation(user_id, user_time);
|
Metrics::init_user_information(user_id, user_time);
|
||||||
Metrics::SetUserInformation(user_id, user_time);
|
Metrics::set_user_information(user_id, user_time);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
@ -183,23 +183,23 @@ int wmain(const int argc, const wchar_t* const* const argv)
|
|||||||
atexit([]()
|
atexit([]()
|
||||||
{
|
{
|
||||||
auto elapsed_us = g_timer.microseconds();
|
auto elapsed_us = g_timer.microseconds();
|
||||||
Metrics::TrackMetric("elapsed_us", elapsed_us);
|
Metrics::track_metric("elapsed_us", elapsed_us);
|
||||||
Metrics::Flush();
|
Metrics::flush();
|
||||||
});
|
});
|
||||||
|
|
||||||
Metrics::TrackProperty("version", Commands::Version::version());
|
Metrics::track_property("version", Commands::Version::version());
|
||||||
|
|
||||||
const std::string trimmed_command_line = trim_path_from_command_line(Strings::utf16_to_utf8(GetCommandLineW()));
|
const std::string trimmed_command_line = trim_path_from_command_line(Strings::utf16_to_utf8(GetCommandLineW()));
|
||||||
Metrics::TrackProperty("cmdline", trimmed_command_line);
|
Metrics::track_property("cmdline", trimmed_command_line);
|
||||||
loadConfig();
|
loadConfig();
|
||||||
Metrics::TrackProperty("sqmuser", Metrics::GetSQMUser());
|
Metrics::track_property("sqmuser", Metrics::get_SQM_user());
|
||||||
|
|
||||||
const vcpkg_cmd_arguments args = vcpkg_cmd_arguments::create_from_command_line(argc, argv);
|
const vcpkg_cmd_arguments args = vcpkg_cmd_arguments::create_from_command_line(argc, argv);
|
||||||
|
|
||||||
if (args.printmetrics != opt_bool_t::UNSPECIFIED)
|
if (args.printmetrics != opt_bool_t::UNSPECIFIED)
|
||||||
Metrics::SetPrintMetrics(args.printmetrics == opt_bool_t::ENABLED);
|
Metrics::set_print_metrics(args.printmetrics == opt_bool_t::ENABLED);
|
||||||
if (args.sendmetrics != opt_bool_t::UNSPECIFIED)
|
if (args.sendmetrics != opt_bool_t::UNSPECIFIED)
|
||||||
Metrics::SetSendMetrics(args.sendmetrics == opt_bool_t::ENABLED);
|
Metrics::set_send_metrics(args.sendmetrics == opt_bool_t::ENABLED);
|
||||||
|
|
||||||
if (args.debug != opt_bool_t::UNSPECIFIED)
|
if (args.debug != opt_bool_t::UNSPECIFIED)
|
||||||
{
|
{
|
||||||
@ -226,7 +226,7 @@ int wmain(const int argc, const wchar_t* const* const argv)
|
|||||||
{
|
{
|
||||||
exc_msg = "unknown error(...)";
|
exc_msg = "unknown error(...)";
|
||||||
}
|
}
|
||||||
Metrics::TrackProperty("error", exc_msg);
|
Metrics::track_property("error", exc_msg);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
System::print(
|
System::print(
|
||||||
|
@ -26,7 +26,7 @@ namespace vcpkg::Input
|
|||||||
if (!paths.is_valid_triplet(t))
|
if (!paths.is_valid_triplet(t))
|
||||||
{
|
{
|
||||||
System::println(System::color::error, "Error: invalid triplet: %s", t.canonical_name());
|
System::println(System::color::error, "Error: invalid triplet: %s", t.canonical_name());
|
||||||
Metrics::TrackProperty("error", "invalid triplet: " + t.canonical_name());
|
Metrics::track_property("error", "invalid triplet: " + t.canonical_name());
|
||||||
Commands::Help::help_topic_valid_triplet(paths);
|
Commands::Help::help_topic_valid_triplet(paths);
|
||||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace vcpkg
|
|||||||
if (arg_begin == arg_end)
|
if (arg_begin == arg_end)
|
||||||
{
|
{
|
||||||
System::println(System::color::error, "Error: expected value after %s", option_name);
|
System::println(System::color::error, "Error: expected value after %s", option_name);
|
||||||
Metrics::TrackProperty("error", "error option name");
|
Metrics::track_property("error", "error option name");
|
||||||
Commands::Help::print_usage();
|
Commands::Help::print_usage();
|
||||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@ namespace vcpkg
|
|||||||
if (option_field != nullptr)
|
if (option_field != nullptr)
|
||||||
{
|
{
|
||||||
System::println(System::color::error, "Error: %s specified multiple times", option_name);
|
System::println(System::color::error, "Error: %s specified multiple times", option_name);
|
||||||
Metrics::TrackProperty("error", "error option specified multiple times");
|
Metrics::track_property("error", "error option specified multiple times");
|
||||||
Commands::Help::print_usage();
|
Commands::Help::print_usage();
|
||||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ namespace vcpkg
|
|||||||
if (option_field != opt_bool_t::UNSPECIFIED && option_field != new_setting)
|
if (option_field != opt_bool_t::UNSPECIFIED && option_field != new_setting)
|
||||||
{
|
{
|
||||||
System::println(System::color::error, "Error: conflicting values specified for --%s", option_name);
|
System::println(System::color::error, "Error: conflicting values specified for --%s", option_name);
|
||||||
Metrics::TrackProperty("error", "error conflicting switches");
|
Metrics::track_property("error", "error conflicting switches");
|
||||||
Commands::Help::print_usage();
|
Commands::Help::print_usage();
|
||||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ namespace vcpkg
|
|||||||
|
|
||||||
if (arg[0] == '-' && arg[1] != '-')
|
if (arg[0] == '-' && arg[1] != '-')
|
||||||
{
|
{
|
||||||
Metrics::TrackProperty("error", "error short options are not supported");
|
Metrics::track_property("error", "error short options are not supported");
|
||||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Error: short options are not supported: %s", arg);
|
Checks::exit_with_message(VCPKG_LINE_INFO, "Error: short options are not supported: %s", arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,5 +13,5 @@ int WINAPI WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPSTR, _In_ int)
|
|||||||
szArgList = CommandLineToArgvW(GetCommandLineW(), &argCount);
|
szArgList = CommandLineToArgvW(GetCommandLineW(), &argCount);
|
||||||
|
|
||||||
Checks::check_exit(VCPKG_LINE_INFO, argCount == 2, "Requires exactly one argument, the path to the payload file");
|
Checks::check_exit(VCPKG_LINE_INFO, argCount == 2, "Requires exactly one argument, the path to the payload file");
|
||||||
Metrics::Upload(Files::read_contents(szArgList[1]).value_or_exit(VCPKG_LINE_INFO));
|
Metrics::upload(Files::read_contents(szArgList[1]).value_or_exit(VCPKG_LINE_INFO));
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,8 @@ namespace vcpkg
|
|||||||
if (rc.exit_code)
|
if (rc.exit_code)
|
||||||
{
|
{
|
||||||
System::println(System::color::error, "Launching powershell failed or was denied");
|
System::println(System::color::error, "Launching powershell failed or was denied");
|
||||||
Metrics::TrackProperty("error", "powershell install failed");
|
Metrics::track_property("error", "powershell install failed");
|
||||||
Metrics::TrackProperty("installcmd", install_cmd);
|
Metrics::track_property("installcmd", install_cmd);
|
||||||
Checks::exit_with_code(VCPKG_LINE_INFO, rc.exit_code);
|
Checks::exit_with_code(VCPKG_LINE_INFO, rc.exit_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ namespace vcpkg
|
|||||||
|
|
||||||
if (paths.root.empty())
|
if (paths.root.empty())
|
||||||
{
|
{
|
||||||
Metrics::TrackProperty("error", "Invalid vcpkg root directory");
|
Metrics::track_property("error", "Invalid vcpkg root directory");
|
||||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Invalid vcpkg root directory: %s", paths.root.string());
|
Checks::exit_with_message(VCPKG_LINE_INFO, "Invalid vcpkg root directory: %s", paths.root.string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ namespace vcpkg
|
|||||||
if (!was_tracked)
|
if (!was_tracked)
|
||||||
{
|
{
|
||||||
was_tracked = true;
|
was_tracked = true;
|
||||||
Metrics::TrackProperty("listfile", "update to new format");
|
Metrics::track_property("listfile", "update to new format");
|
||||||
}
|
}
|
||||||
|
|
||||||
// The files are sorted such that directories are placed just before the files they contain
|
// The files are sorted such that directories are placed just before the files they contain
|
||||||
|
Loading…
x
Reference in New Issue
Block a user