diff --git a/chrome/browser/metrics/structured/BUILD.gn b/chrome/browser/metrics/structured/BUILD.gn index 96e04329045ec9..d18f1ce02920cb 100644 --- a/chrome/browser/metrics/structured/BUILD.gn +++ b/chrome/browser/metrics/structured/BUILD.gn @@ -18,6 +18,7 @@ static_library("structured") { "//build:chromeos_buildflags", "//chromeos/crosapi/mojom", "//components/metrics/structured", + "//components/metrics/structured:structured_events", ] if (is_chromeos_ash) { diff --git a/chrome/browser/metrics/structured/chrome_structured_metrics_recorder.cc b/chrome/browser/metrics/structured/chrome_structured_metrics_recorder.cc index b386bce42a8285..f4ccf1ec000dd5 100644 --- a/chrome/browser/metrics/structured/chrome_structured_metrics_recorder.cc +++ b/chrome/browser/metrics/structured/chrome_structured_metrics_recorder.cc @@ -4,6 +4,8 @@ #include "chrome/browser/metrics/structured/chrome_structured_metrics_recorder.h" +#include + #include "base/feature_list.h" #include "build/chromeos_buildflags.h" #include "components/metrics/structured/histogram_util.h" @@ -19,6 +21,23 @@ #endif namespace metrics { namespace structured { +namespace { + +// Platforms for which the StructuredMetricsClient will be initialized for. +enum class StructuredMetricsPlatform { + kUninitialized = 0, + kAshChrome = 1, + kLacrosChrome = 2, +}; + +// Logs initialization of Structured Metrics as a record. +void LogInitializationInStructuredMetrics(StructuredMetricsPlatform platform) { + events::v2::structured_metrics::Initialization() + .SetPlatform(static_cast(platform)) + .Record(); +} + +} // namespace ChromeStructuredMetricsRecorder::ChromeStructuredMetricsRecorder() { // TODO(jongahn): Make a static factory class and pass it into ctor. @@ -53,6 +72,7 @@ void ChromeStructuredMetricsRecorder::Initialize() { auto* ash_recorder = static_cast(delegate_.get()); ash_recorder->Initialize(); + LogInitializationInStructuredMetrics(StructuredMetricsPlatform::kAshChrome); #elif BUILDFLAG(IS_CHROMEOS_LACROS) // Should only be enabled on Lacros if feature is enabled. @@ -66,6 +86,12 @@ void ChromeStructuredMetricsRecorder::Initialize() { // Ensure that the sequence is the ui thread. DCHECK(is_current_ui_thread_set); lacros_recorder->SetSequence(base::SequencedTaskRunnerHandle::Get()); + LogClientInitializationSuccessful(true); + LogInitializationInStructuredMetrics( + StructuredMetricsPlatform::kLacrosChrome); + } else { + LogInitializationInStructuredMetrics( + StructuredMetricsPlatform::kUninitialized); } #endif } diff --git a/chrome/browser/metrics/structured/chrome_structured_metrics_recorder.h b/chrome/browser/metrics/structured/chrome_structured_metrics_recorder.h index 0b07262c9d17d5..52548c73b36c4d 100644 --- a/chrome/browser/metrics/structured/chrome_structured_metrics_recorder.h +++ b/chrome/browser/metrics/structured/chrome_structured_metrics_recorder.h @@ -11,13 +11,14 @@ #include "components/metrics/structured/event.h" #include "components/metrics/structured/event_base.h" #include "components/metrics/structured/structured_metrics_client.h" +#include "components/metrics/structured/structured_mojo_events.h" namespace metrics { namespace structured { namespace { using RecordingDelegate = StructuredMetricsClient::RecordingDelegate; -} +} // namespace // Singleton to record structured metrics on Chrome. // diff --git a/tools/metrics/structured/structured.xml b/tools/metrics/structured/structured.xml index f36b6118d4f470..c54c47086c61f5 100644 --- a/tools/metrics/structured/structured.xml +++ b/tools/metrics/structured/structured.xml @@ -378,6 +378,31 @@ + + jongahn@chromium.org + tby@chromium.org + per-project + device + + Structured Metrics is a logging framework for events. This project is used + for monitoring the framework itself. + + + + + Records metadata about initialization of Structured Metrics and will be + recorded immediately after initialization is successful. Will be sent once + per initialization during browser process initialization. + + + + The platform for which the client is initialized on. 0: Uninitialized, 1: + ASH_CHROME, 2: LACROS_CHROME. + + + + + tby@chromium.org per-project