-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[telemetry] Refactor track_property()
#685
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
37bf289
initialize timestamp in metrics message
vicroms 2f7e0b2
refactor track_property()
vicroms e7b2a88
Merge branch 'main' of https://github.com/microsoft/vcpkg-tool into t…
vicroms ef11cfa
Update src/vcpkg/vcpkgpaths.cpp
vicroms c4ff3d1
Remove `track_option()`
vicroms caf08c7
Renamed SetMetric to DefineMetric
vicroms 109ae2b
Never trust VS's `Ctrl+R,Ctrl+R`
vicroms 2e783ed
Add missing metric name
vicroms e0f287a
format
vicroms 012deb6
Partially address Robert's comments
vicroms a5316e5
Change `track_property()` call sites
vicroms c2e0f50
Review comments and tests
vicroms ff56e69
Update src/vcpkg-test/metrics.cpp
vicroms c15a4a5
simplify tests
vicroms c65d211
Remove `track_property()` overrides
vicroms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these referred to more than once? If not, I think the previous form was actually better since we didn't have to decode the enum to a string and back again.
If you keep this, we probably should have a comment about how adding new entries needs to be classified vis a vis GDPR and all that stuff?