1 // Copyright 2021 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_STRUCTURED_METRICS_FEATURES_H_ 6 #define COMPONENTS_METRICS_STRUCTURED_STRUCTURED_METRICS_FEATURES_H_ 7 8 #include "base/feature_list.h" 9 #include "base/metrics/field_trial_params.h" 10 #include "base/time/time.h" 11 12 namespace metrics::features { 13 // This is forward-declared since this file cannot have a direct dependency on 14 // //components/metrics to avoid circular dependencies. This feature is defined 15 // in //components/metrics/metrics_features.cc. 16 BASE_DECLARE_FEATURE(kStructuredMetrics); 17 18 } // namespace metrics::features 19 20 namespace metrics::structured { 21 22 // Controls whether the structured metrics service is recorder instead of the 23 // provider. 24 BASE_DECLARE_FEATURE(kEnabledStructuredMetricsService); 25 26 // Controls whether Phone Hub Structured Metrics is enabled or not. 27 BASE_DECLARE_FEATURE(kPhoneHubStructuredMetrics); 28 29 // Controls whether the new storage manager is used to manage events. 30 BASE_DECLARE_FEATURE(kEventStorageManager); 31 32 // Controls the minimum number of logs to be stored. 33 extern const base::FeatureParam<int> kMinLogQueueCount; 34 35 // Controls the minimum size of all logs that can be stored in bytes. 36 extern const base::FeatureParam<int> kMinLogQueueSizeBytes; 37 38 // Controls the maximum size of a single log in bytes. 39 extern const base::FeatureParam<int> kMaxLogSizeBytes; 40 41 // Returns the parameter used to control how many files will be read into memory 42 // before events start being discarded. 43 // 44 // This is to prevent too many files to be read into memory, causing Chrome to 45 // OOM. 46 int GetFileLimitPerScan(); 47 48 // Returns the parameter used to control the max size of an event. Any event 49 // exceeding this memory limit will be discarded. Defaults to 50KB. 50 int GetFileSizeByteLimit(); 51 52 // Returns the upload cadence in minutes for which events are uploaded to the 53 // UMA service to either be persisted as logs or uploaded. 54 int GetUploadCadenceMinutes(); 55 56 // Returns the KiB proto limit per log. Events will not be added if the current 57 // log exceeds the proto limit and events will be dropped if exceeded. 58 int GetProtoKiBLimit(); 59 60 // Returns the parameter used to control what projects are allowed to be 61 // recorded. 62 std::string GetDisabledProjects(); 63 64 // Retrieves the Structured Metrics upload interval (defaults to 40 minutes). 65 int GetUploadInterval(); 66 67 // Retrieves the collection interval for external metrics (defaults to 10 68 // minutes). 69 base::TimeDelta GetExternalMetricsCollectionInterval(); 70 71 // Retrieves the interval in which events are periodically backed up to disk 72 // while still available in-memory. 73 base::TimeDelta GetBackupTimeDelta(); 74 75 // Returns the percentage of memory size that can be used for storing in-memory 76 // events. 77 double GetMaxBufferSizeRatio(); 78 79 // Returns the percentage of writable disk space that can be used for storing 80 // flushed events. 81 double GetMaxDiskSizeRatio(); 82 83 } // namespace metrics::structured 84 85 #endif // COMPONENTS_METRICS_STRUCTURED_STRUCTURED_METRICS_FEATURES_H_ 86