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 event sequence logging is enabled or not. 23 BASE_DECLARE_FEATURE(kEventSequenceLogging); 24 25 BASE_DECLARE_FEATURE(kBluetoothSessionizedMetrics); 26 27 // Controls whether fast pair logging is enabled or not. 28 BASE_DECLARE_FEATURE(kFastPairMetrics); 29 30 // Controls whether nearby share logging is enabled or not. 31 BASE_DECLARE_FEATURE(kNearbyShareMetrics); 32 33 // Controls whether the structured metrics service is recorder instead of the 34 // provider. 35 BASE_DECLARE_FEATURE(kEnabledStructuredMetricsService); 36 37 // Controls whether Phone Hub Structured Metrics is enabled or not. 38 BASE_DECLARE_FEATURE(kPhoneHubStructuredMetrics); 39 40 // Controls the minimum number of logs to be stored. 41 extern const base::FeatureParam<int> kMinLogQueueCount; 42 43 // Controls the minimum size of all logs that can be stored in bytes. 44 extern const base::FeatureParam<int> kMinLogQueueSizeBytes; 45 46 // Controls the maximum size of a single log in bytes. 47 extern const base::FeatureParam<int> kMaxLogSizeBytes; 48 49 // TODO(crbug.com/1148168): This is a temporary switch to revert structured 50 // metrics upload to its old behaviour. Old behaviour: 51 // - all metrics are uploaded in the main UMA upload 52 // 53 // New behaviour: 54 // - Projects with id type 'uma' are uploaded in the main UMA uploaded 55 // - Projects with id type 'project-id' or 'none' are uploaded independently. 56 // 57 // Once we are comfortable with this change, this parameter can be removed. 58 bool IsIndependentMetricsUploadEnabled(); 59 60 // Returns the parameter used to control how many files will be read into memory 61 // before events start being discarded. 62 // 63 // This is to prevent too many files to be read into memory, causing Chrome to 64 // OOM. 65 int GetFileLimitPerScan(); 66 67 // Returns the parameter used to control the max size of an event. Any event 68 // exceeding this memory limit will be discarded. Defaults to 50KB. 69 int GetFileSizeByteLimit(); 70 71 // Returns the upload cadence in minutes for which events are uploaded to the 72 // UMA service to either be persisted as logs or uploaded. 73 int GetUploadCadenceMinutes(); 74 75 // Returns the KiB proto limit per log. Events will not be added if the current 76 // log exceeds the proto limit and events will be dropped if exceeded. 77 int GetProtoKiBLimit(); 78 79 // Returns the parameter used to control what projects are allowed to be 80 // recorded. 81 std::string GetDisabledProjects(); 82 83 // Retrieves the Structured Metrics upload interval (defaults to 40 minutes). 84 int GetUploadInterval(); 85 86 // Retrieves the collection interval for external metrics (defaults to 10 87 // minutes). 88 base::TimeDelta GetExternalMetricsCollectionInterval(); 89 90 } // namespace metrics::structured 91 92 #endif // COMPONENTS_METRICS_STRUCTURED_STRUCTURED_METRICS_FEATURES_H_ 93