-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[telemetry] Refactor
track_property()
(#685)
* initialize timestamp in metrics message * refactor track_property() * Update src/vcpkg/vcpkgpaths.cpp * Remove `track_option()` * Renamed SetMetric to DefineMetric * Never trust VS's `Ctrl+R,Ctrl+R` * Add missing metric name * format * Partially address Robert's comments * Change `track_property()` call sites * Review comments and tests * Update src/vcpkg-test/metrics.cpp Co-authored-by: Robert Schumacher <roschuma@microsoft.com> * simplify tests * Remove `track_property()` overrides Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
- Loading branch information
1 parent
8569748
commit 3fa3fb5
Showing
18 changed files
with
299 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <catch2/catch.hpp> | ||
|
||
#include <vcpkg/metrics.h> | ||
|
||
#include <set> | ||
|
||
using namespace vcpkg; | ||
|
||
template<typename T> | ||
void validate_enum_values_and_names(View<MetricEntry<T>> entries, const size_t expected_size) | ||
{ | ||
REQUIRE(expected_size == entries.size()); | ||
|
||
size_t enum_value = 0; | ||
std::set<StringView> used_names; | ||
for (auto&& m : entries) | ||
{ | ||
// fails when a metric is not in the right order in the entries array | ||
// - check that there are no duplicate or skipped metric entries | ||
// - check that the order in Metrics::get_<T>_metrics() and in the <T>Metric enum is the same | ||
REQUIRE(static_cast<size_t>(m.metric) == enum_value); | ||
++enum_value; | ||
|
||
// fails when there's a repeated metric name | ||
REQUIRE(!m.name.empty()); | ||
auto it_names = used_names.find(m.name); | ||
REQUIRE(it_names == used_names.end()); | ||
used_names.insert(m.name); | ||
} | ||
} | ||
|
||
TEST_CASE ("Check metric enum types", "[metrics]") | ||
{ | ||
SECTION ("define metrics") | ||
{ | ||
validate_enum_values_and_names(Metrics::get_define_metrics(), static_cast<size_t>(DefineMetric::COUNT)); | ||
} | ||
|
||
SECTION ("string metrics") | ||
{ | ||
validate_enum_values_and_names(Metrics::get_string_metrics(), static_cast<size_t>(StringMetric::COUNT)); | ||
} | ||
|
||
SECTION ("bool metrics") | ||
{ | ||
validate_enum_values_and_names(Metrics::get_bool_metrics(), static_cast<size_t>(BoolMetric::COUNT)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.