Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/vcpkg/registries.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace vcpkg

struct RegistryImplementation
{
virtual StringLiteral kind() const = 0;

// returns nullptr if the port doesn't exist
virtual std::unique_ptr<RegistryEntry> get_port_entry(const VcpkgPaths& paths, StringView port_name) const = 0;

Expand Down
2 changes: 2 additions & 0 deletions src/vcpkg-test/registries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace
{
struct TestRegistryImplementation final : RegistryImplementation
{
StringLiteral kind() const override { return "test"; }

std::unique_ptr<RegistryEntry> get_port_entry(const VcpkgPaths&, StringView) const override { return nullptr; }

void get_all_port_names(std::vector<std::string>&, const VcpkgPaths&) const override { }
Expand Down
3 changes: 3 additions & 0 deletions src/vcpkg/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <vcpkg/base/system.print.h>

#include <vcpkg/configuration.h>
#include <vcpkg/metrics.h>
#include <vcpkg/vcpkgcmdarguments.h>

namespace
Expand Down Expand Up @@ -74,6 +75,8 @@ namespace vcpkg
{
if (!flags.registries && registry_set.has_modifications())
{
Metrics::g_metrics.lock()->track_property("registries-error-registry-modification-without-feature-flag",
"defined");
System::printf(System::Color::warning,
"Warning: configuration specified the \"registries\" or \"default-registries\" field, but "
"the %s feature flag was not enabled.\n",
Expand Down
14 changes: 13 additions & 1 deletion src/vcpkg/registries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <vcpkg/base/jsonreader.h>
#include <vcpkg/base/system.debug.h>

#include <vcpkg/metrics.h>
#include <vcpkg/paragraphs.h>
#include <vcpkg/registries.h>
#include <vcpkg/sourceparagraph.h>
Expand Down Expand Up @@ -45,6 +46,8 @@ namespace
{
}

StringLiteral kind() const override { return "git"; }

std::unique_ptr<RegistryEntry> get_port_entry(const VcpkgPaths&, StringView) const override;

void get_all_port_names(std::vector<std::string>&, const VcpkgPaths&) const override;
Expand Down Expand Up @@ -73,6 +76,7 @@ namespace
registry_versions_dir_name);
if (!maybe_tree)
{
Metrics::g_metrics.lock()->track_property("registries-error-no-versions-at-commit", "defined");
Checks::exit_with_message(
VCPKG_LINE_INFO,
"Error: could not find the git tree for `versions` in repo `%s` at commit `%s`: %s",
Expand All @@ -84,7 +88,7 @@ namespace
if (!maybe_path)
{
Checks::exit_with_message(VCPKG_LINE_INFO,
"Error: failed to check out `port_versions` from repo %s: %s",
"Error: failed to check out `versions` from repo %s: %s",
m_repo,
maybe_path.error());
}
Expand Down Expand Up @@ -158,6 +162,8 @@ namespace
Debug::print("BuiltinRegistry initialized with: \"", m_baseline_identifier, "\"\n");
}

StringLiteral kind() const override { return "builtin"; }

std::unique_ptr<RegistryEntry> get_port_entry(const VcpkgPaths& paths, StringView port_name) const override;

void get_all_port_names(std::vector<std::string>&, const VcpkgPaths&) const override;
Expand All @@ -177,6 +183,8 @@ namespace
{
}

StringLiteral kind() const override { return "filesystem"; }

std::unique_ptr<RegistryEntry> get_port_entry(const VcpkgPaths&, StringView) const override;

void get_all_port_names(std::vector<std::string>&, const VcpkgPaths&) const override;
Expand Down Expand Up @@ -524,6 +532,7 @@ namespace

if (m_baseline_identifier == "default")
{
Metrics::g_metrics.lock()->track_property("registries-error-could-not-find-baseline", "defined");
Checks::exit_with_message(
VCPKG_LINE_INFO,
"Couldn't find explicitly specified baseline `\"default\"` in the baseline file.",
Expand All @@ -534,6 +543,7 @@ namespace
auto explicit_hash = paths.git_fetch_from_remote_registry(m_repo, m_baseline_identifier);
if (!explicit_hash.has_value())
{
Metrics::g_metrics.lock()->track_property("registries-error-could-not-find-baseline", "defined");
Checks::exit_with_message(
VCPKG_LINE_INFO,
"Error: Couldn't find explicitly specified baseline `\"%s\"` in the baseline file for repo %s, "
Expand All @@ -546,6 +556,7 @@ namespace
auto maybe_contents = paths.git_show_from_remote_registry(*explicit_hash.get(), path_to_baseline);
if (!maybe_contents.has_value())
{
Metrics::g_metrics.lock()->track_property("registries-error-could-not-find-baseline", "defined");
Checks::exit_with_message(
VCPKG_LINE_INFO,
"Error: Couldn't find explicitly specified baseline `\"%s\"` in the baseline file for repo %s, "
Expand All @@ -568,6 +579,7 @@ namespace
}
else
{
Metrics::g_metrics.lock()->track_property("registries-error-could-not-find-baseline", "defined");
Checks::exit_maybe_upgrade(
VCPKG_LINE_INFO,
"Couldn't find explicitly specified baseline `\"%s\"` in the baseline file for repo %s, "
Expand Down
27 changes: 27 additions & 0 deletions src/vcpkg/vcpkgpaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,33 @@ If you wish to silence this error and use classic mode, you can:

auto config_file = load_configuration(filesystem, args, root, manifest_root_dir);

// metrics from configuration
{
auto default_registry = config_file.config.registry_set.default_registry();
auto other_registries = config_file.config.registry_set.registries();
auto metrics = Metrics::g_metrics.lock();

if (default_registry)
{
metrics->track_property("registries-default-registry-kind", default_registry->kind());
}
else
{
metrics->track_property("registries-default-registry-kind", "disabled");
}

if (other_registries.size() != 0)
{
std::vector<StringLiteral> registry_kinds;
for (const auto& reg : other_registries)
{
registry_kinds.push_back(reg.implementation().kind());
}
Util::sort_unique_erase(registry_kinds);
metrics->track_property("registries-kinds-used", Strings::join(",", registry_kinds));
}
}

config_root_dir = std::move(config_file.config_directory);
m_pimpl->m_config = std::move(config_file.config);

Expand Down