1 // Copyright 2020 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_METRICS_STRUCTURED_HISTOGRAM_UTIL_H_ 6 #define COMPONENTS_METRICS_STRUCTURED_HISTOGRAM_UTIL_H_ 7 8 #include <string_view> 9 10 #include "components/prefs/persistent_pref_store.h" 11 12 namespace metrics::structured { 13 14 // Whether a single event was recorded correctly, or otherwise what error state 15 // occurred. These values are persisted to logs. Entries should not be 16 // renumbered and numeric values should never be reused. 17 enum class EventRecordingState { 18 kRecorded = 0, 19 kProviderUninitialized = 1, 20 kRecordingDisabled = 2, 21 kProviderMissing = 3, 22 kProjectDisallowed = 4, 23 kLogSizeExceeded = 5, 24 kMaxValue = kLogSizeExceeded, 25 }; 26 27 void LogEventRecordingState(EventRecordingState state); 28 29 // Log how many structured metrics events were contained in a call to 30 // ProvideCurrentSessionData. 31 void LogNumEventsInUpload(int num_events); 32 33 // Logs the number of events that were recorded before device and user 34 // cryptographic keys have been loaded to hash events. These events will be kept 35 // in memory. 36 void LogNumEventsRecordedBeforeInit(int num_events); 37 38 // Logs the number of files processed per external metrics scan. 39 void LogNumFilesPerExternalMetricsScan(int num_files); 40 41 // Logs the file size of an event. 42 void LogEventFileSizeKB(int64_t file_size_kb); 43 44 // Logs the serialized size of an event when it is recorded in bytes. 45 void LogEventSerializedSizeBytes(int64_t event_size_bytes); 46 47 // Logs the StructuredMetrics uploaded size to UMA in bytes. 48 void LogUploadSizeBytes(int64_t upload_size_bytes); 49 50 // Logs the number of external metrics were scanned for an upload. 51 void LogExternalMetricsScanInUpload(int num_scans); 52 53 // Logs the number of external metrics that were dropped. 54 void LogDroppedExternalMetrics(int num_dropped); 55 56 // Logs the number of external metrics that were dropped per-project. 57 void LogDroppedProjectExternalMetrics(std::string_view project_name, 58 int num_dropped); 59 60 // Logs the number of external metrics produced per-project. 61 void LogProducedProjectExternalMetrics(std::string_view project_name, 62 int num_produced); 63 64 } // namespace metrics::structured 65 66 #endif // COMPONENTS_METRICS_STRUCTURED_HISTOGRAM_UTIL_H_ 67