Commit a5d13f96 authored by tby's avatar tby Committed by Chromium LUCI CQ

Export UMA protos from google3.

This is a run of proto_export.py plus minimal code changes to handle
the deprecation of the ChromeUserMetricsExtension.structured_event.
A follow-up CL will update the code to use the replacement field.

The proto_export.py script also didn't delete structured_event.proto,
so I've done that manually.

Change-Id: I0ac699c1ef399674d9b3a92d41747076093f307c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2631646
Commit-Queue: Tony Yeoman <tby@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844436}
parent acc31c0c
...@@ -48,7 +48,7 @@ void PopulateUmaProto(const base::Value* events, ...@@ -48,7 +48,7 @@ void PopulateUmaProto(const base::Value* events,
ChromeUserMetricsExtension* uma_proto) { ChromeUserMetricsExtension* uma_proto) {
DCHECK(events->is_list()); DCHECK(events->is_list());
for (const auto& event : events->GetList()) { for (const auto& event : events->GetList()) {
auto* event_proto = uma_proto->add_structured_event(); auto* event_proto = uma_proto->add_deprecated_structured_event();
const auto event_name_hash = StringValueToUint(event.FindKey("name")); const auto event_name_hash = StringValueToUint(event.FindKey("name"));
if (!event_name_hash) if (!event_name_hash)
......
...@@ -183,7 +183,7 @@ TEST_F(StructuredMetricsProviderTest, EventsNotReportedWhenRecordingDisabled) { ...@@ -183,7 +183,7 @@ TEST_F(StructuredMetricsProviderTest, EventsNotReportedWhenRecordingDisabled) {
Init(); Init();
OnRecordingDisabled(); OnRecordingDisabled();
events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record(); events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record();
EXPECT_EQ(GetProvidedEvents().structured_event_size(), 0); EXPECT_EQ(GetProvidedEvents().deprecated_structured_event_size(), 0);
ExpectOnlyFileReadError(); ExpectOnlyFileReadError();
} }
...@@ -237,7 +237,7 @@ TEST_F(StructuredMetricsProviderTest, RecordedEventAppearsInReport) { ...@@ -237,7 +237,7 @@ TEST_F(StructuredMetricsProviderTest, RecordedEventAppearsInReport) {
.SetTestMetricTwo(12345) .SetTestMetricTwo(12345)
.Record(); .Record();
EXPECT_EQ(GetProvidedEvents().structured_event_size(), 3); EXPECT_EQ(GetProvidedEvents().deprecated_structured_event_size(), 3);
ExpectOnlyFileReadError(); ExpectOnlyFileReadError();
} }
...@@ -254,10 +254,10 @@ TEST_F(StructuredMetricsProviderTest, EventsReportedCorrectly) { ...@@ -254,10 +254,10 @@ TEST_F(StructuredMetricsProviderTest, EventsReportedCorrectly) {
.Record(); .Record();
const auto uma = GetProvidedEvents(); const auto uma = GetProvidedEvents();
ASSERT_EQ(uma.structured_event_size(), 2); ASSERT_EQ(uma.deprecated_structured_event_size(), 2);
{ // First event { // First event
const auto& event = uma.structured_event(0); const auto& event = uma.deprecated_structured_event(0);
EXPECT_EQ(event.event_name_hash(), kEventOneHash); EXPECT_EQ(event.event_name_hash(), kEventOneHash);
EXPECT_EQ(HashToHex(event.profile_event_id()), kProjectOneId); EXPECT_EQ(HashToHex(event.profile_event_id()), kProjectOneId);
ASSERT_EQ(event.metrics_size(), 2); ASSERT_EQ(event.metrics_size(), 2);
...@@ -279,7 +279,7 @@ TEST_F(StructuredMetricsProviderTest, EventsReportedCorrectly) { ...@@ -279,7 +279,7 @@ TEST_F(StructuredMetricsProviderTest, EventsReportedCorrectly) {
} }
{ // Second event { // Second event
const auto& event = uma.structured_event(1); const auto& event = uma.deprecated_structured_event(1);
EXPECT_EQ(event.event_name_hash(), kEventTwoHash); EXPECT_EQ(event.event_name_hash(), kEventTwoHash);
EXPECT_EQ(HashToHex(event.profile_event_id()), kProjectTwoId); EXPECT_EQ(HashToHex(event.profile_event_id()), kProjectTwoId);
ASSERT_EQ(event.metrics_size(), 1); ASSERT_EQ(event.metrics_size(), 1);
...@@ -307,11 +307,11 @@ TEST_F(StructuredMetricsProviderTest, EventsWithinProjectReportedWithSameID) { ...@@ -307,11 +307,11 @@ TEST_F(StructuredMetricsProviderTest, EventsWithinProjectReportedWithSameID) {
events::test_project_two::TestEventThree().Record(); events::test_project_two::TestEventThree().Record();
const auto uma = GetProvidedEvents(); const auto uma = GetProvidedEvents();
ASSERT_EQ(uma.structured_event_size(), 3); ASSERT_EQ(uma.deprecated_structured_event_size(), 3);
const auto& event_one = uma.structured_event(0); const auto& event_one = uma.deprecated_structured_event(0);
const auto& event_two = uma.structured_event(1); const auto& event_two = uma.deprecated_structured_event(1);
const auto& event_three = uma.structured_event(2); const auto& event_three = uma.deprecated_structured_event(2);
// Check events are in the right order. // Check events are in the right order.
EXPECT_EQ(event_one.event_name_hash(), kEventOneHash); EXPECT_EQ(event_one.event_name_hash(), kEventOneHash);
...@@ -336,14 +336,14 @@ TEST_F(StructuredMetricsProviderTest, EventsClearedAfterReport) { ...@@ -336,14 +336,14 @@ TEST_F(StructuredMetricsProviderTest, EventsClearedAfterReport) {
events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record(); events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record();
events::test_project_one::TestEventOne().SetTestMetricTwo(2).Record(); events::test_project_one::TestEventOne().SetTestMetricTwo(2).Record();
// Should provide both the previous events. // Should provide both the previous events.
EXPECT_EQ(GetProvidedEvents().structured_event_size(), 2); EXPECT_EQ(GetProvidedEvents().deprecated_structured_event_size(), 2);
// But the previous events shouldn't appear in the second report. // But the previous events shouldn't appear in the second report.
EXPECT_EQ(GetProvidedEvents().structured_event_size(), 0); EXPECT_EQ(GetProvidedEvents().deprecated_structured_event_size(), 0);
events::test_project_one::TestEventOne().SetTestMetricTwo(3).Record(); events::test_project_one::TestEventOne().SetTestMetricTwo(3).Record();
// The third request should only contain the third event. // The third request should only contain the third event.
EXPECT_EQ(GetProvidedEvents().structured_event_size(), 1); EXPECT_EQ(GetProvidedEvents().deprecated_structured_event_size(), 1);
ExpectOnlyFileReadError(); ExpectOnlyFileReadError();
} }
...@@ -362,9 +362,9 @@ TEST_F(StructuredMetricsProviderTest, EventsFromPreviousSessionAreReported) { ...@@ -362,9 +362,9 @@ TEST_F(StructuredMetricsProviderTest, EventsFromPreviousSessionAreReported) {
// Start a second session and ensure the event is reported. // Start a second session and ensure the event is reported.
Init(); Init();
const auto uma = GetProvidedEvents(); const auto uma = GetProvidedEvents();
ASSERT_EQ(uma.structured_event_size(), 1); ASSERT_EQ(uma.deprecated_structured_event_size(), 1);
ASSERT_EQ(uma.structured_event(0).metrics_size(), 1); ASSERT_EQ(uma.deprecated_structured_event(0).metrics_size(), 1);
EXPECT_EQ(uma.structured_event(0).metrics(0).value_int64(), 1234); EXPECT_EQ(uma.deprecated_structured_event(0).metrics(0).value_int64(), 1234);
ExpectOnlyFileReadError(); ExpectOnlyFileReadError();
} }
...@@ -384,7 +384,7 @@ TEST_F(StructuredMetricsProviderTest, EventsNotRecordedBeforeInitialization) { ...@@ -384,7 +384,7 @@ TEST_F(StructuredMetricsProviderTest, EventsNotRecordedBeforeInitialization) {
// done, because the provider hasn't finished loading the keys from disk. // done, because the provider hasn't finished loading the keys from disk.
events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record(); events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record();
Wait(); Wait();
EXPECT_EQ(GetProvidedEvents().structured_event_size(), 0); EXPECT_EQ(GetProvidedEvents().deprecated_structured_event_size(), 0);
ExpectOnlyFileReadError(); ExpectOnlyFileReadError();
} }
...@@ -399,7 +399,7 @@ TEST_F(StructuredMetricsProviderTest, ...@@ -399,7 +399,7 @@ TEST_F(StructuredMetricsProviderTest,
events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record(); events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record();
OnRecordingDisabled(); OnRecordingDisabled();
events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record(); events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record();
EXPECT_EQ(GetProvidedEvents().structured_event_size(), 0); EXPECT_EQ(GetProvidedEvents().deprecated_structured_event_size(), 0);
ExpectOnlyFileReadError(); ExpectOnlyFileReadError();
} }
...@@ -416,7 +416,7 @@ TEST_F(StructuredMetricsProviderTest, ReportingResumesWhenEnabled) { ...@@ -416,7 +416,7 @@ TEST_F(StructuredMetricsProviderTest, ReportingResumesWhenEnabled) {
OnRecordingEnabled(); OnRecordingEnabled();
events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record(); events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record();
events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record(); events::test_project_one::TestEventOne().SetTestMetricTwo(1).Record();
EXPECT_EQ(GetProvidedEvents().structured_event_size(), 2); EXPECT_EQ(GetProvidedEvents().deprecated_structured_event_size(), 2);
ExpectOnlyFileReadError(); ExpectOnlyFileReadError();
} }
...@@ -426,11 +426,11 @@ TEST_F(StructuredMetricsProviderTest, ReportingResumesWhenEnabled) { ...@@ -426,11 +426,11 @@ TEST_F(StructuredMetricsProviderTest, ReportingResumesWhenEnabled) {
TEST_F(StructuredMetricsProviderTest, TEST_F(StructuredMetricsProviderTest,
ReportsNothingBeforeInitializationComplete) { ReportsNothingBeforeInitializationComplete) {
provider_ = std::make_unique<StructuredMetricsProvider>(); provider_ = std::make_unique<StructuredMetricsProvider>();
EXPECT_EQ(GetProvidedEvents().structured_event_size(), 0); EXPECT_EQ(GetProvidedEvents().deprecated_structured_event_size(), 0);
OnRecordingEnabled(); OnRecordingEnabled();
EXPECT_EQ(GetProvidedEvents().structured_event_size(), 0); EXPECT_EQ(GetProvidedEvents().deprecated_structured_event_size(), 0);
OnProfileAdded(TempDirPath()); OnProfileAdded(TempDirPath());
EXPECT_EQ(GetProvidedEvents().structured_event_size(), 0); EXPECT_EQ(GetProvidedEvents().deprecated_structured_event_size(), 0);
} }
// Ensure an old structured_metrics.json file correctly migrates to the new // Ensure an old structured_metrics.json file correctly migrates to the new
......
...@@ -25,7 +25,7 @@ _proto_files = [ ...@@ -25,7 +25,7 @@ _proto_files = [
"printer_event.proto", "printer_event.proto",
"reporting_info.proto", "reporting_info.proto",
"sampled_profile.proto", "sampled_profile.proto",
"structured_event.proto", "structured_data.proto",
"system_profile.proto", "system_profile.proto",
"trace_log.proto", "trace_log.proto",
"translate_event.proto", "translate_event.proto",
......
Name: Metrics Protos Name: Metrics Protos
Short Name: metrics_proto Short Name: metrics_proto
URL: This is the canonical public repository URL: This is the canonical public repository
Version: 346104568 Version: 351916971
Date: 2020/12/07 UTC Date: 2021/01/15 UTC
License: BSD License: BSD
Security Critical: Yes Security Critical: Yes
......
...@@ -21,14 +21,14 @@ import "perf_data.proto"; ...@@ -21,14 +21,14 @@ import "perf_data.proto";
import "printer_event.proto"; import "printer_event.proto";
import "reporting_info.proto"; import "reporting_info.proto";
import "sampled_profile.proto"; import "sampled_profile.proto";
import "structured_event.proto"; import "structured_data.proto";
import "system_profile.proto"; import "system_profile.proto";
import "trace_log.proto"; import "trace_log.proto";
import "translate_event.proto"; import "translate_event.proto";
import "user_action_event.proto"; import "user_action_event.proto";
import "user_demographics.proto"; import "user_demographics.proto";
// Next tag: 23 // Next tag: 24
message ChromeUserMetricsExtension { message ChromeUserMetricsExtension {
// The product (i.e. end user application) for a given UMA log. // The product (i.e. end user application) for a given UMA log.
enum Product { enum Product {
...@@ -89,7 +89,10 @@ message ChromeUserMetricsExtension { ...@@ -89,7 +89,10 @@ message ChromeUserMetricsExtension {
repeated PrinterEventProto printer_event = 16; repeated PrinterEventProto printer_event = 16;
repeated ChromeOSAppListLaunchEventProto chrome_os_app_list_launch_event = 20; repeated ChromeOSAppListLaunchEventProto chrome_os_app_list_launch_event = 20;
repeated StructuredEventProto structured_event = 22; repeated StructuredEventProto deprecated_structured_event = 22
[deprecated = true];
optional StructuredDataProto structured_data = 23;
// Deprecated: use |sampled_profile| instead. // Deprecated: use |sampled_profile| instead.
repeated PerfDataProto perf_data = 8 [deprecated = true]; repeated PerfDataProto perf_data = 8 [deprecated = true];
......
...@@ -149,6 +149,9 @@ message ExtensionInstallProto { ...@@ -149,6 +149,9 @@ message ExtensionInstallProto {
DISABLE_REMOTELY_FOR_MALWARE = 15; DISABLE_REMOTELY_FOR_MALWARE = 15;
// The extension is being reinstalled. // The extension is being reinstalled.
REINSTALL = 16; REINSTALL = 16;
// The extension has been disabled because it's not allowlisted and the Safe
// Browsing allowlist is enforced in the user profile.
NOT_ALLOWLISTED = 17;
} }
// Any DisableReasons in effect for the extension. An empty list means the // Any DisableReasons in effect for the extension. An empty list means the
// extension is not disabled. Note that an extension that is not disabled may // extension is not disabled. Note that an extension that is not disabled may
......
...@@ -52,3 +52,10 @@ message StructuredEventProto { ...@@ -52,3 +52,10 @@ message StructuredEventProto {
} }
repeated Metric metrics = 3; repeated Metric metrics = 3;
} }
// The top-level proto for structured metrics. One StructuredDataProto is
// uploaded per UMA upload containing structured metrics. Contains all
// structured events for that upload, and any other metadata.
message StructuredDataProto {
repeated StructuredEventProto events = 1;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment