1 // Copyright 2016 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_UNSENT_LOG_STORE_METRICS_H_ 6 #define COMPONENTS_METRICS_UNSENT_LOG_STORE_METRICS_H_ 7 8 #include "base/feature_list.h" 9 #include "components/metrics/unsent_log_store.h" 10 11 namespace metrics { 12 13 // The feature to record the unsent log info metrics, refer to 14 // UnsentLogStoreMetricsImpl::RecordLastUnsentLogMetadataMetrics. 15 BASE_DECLARE_FEATURE(kRecordLastUnsentLogMetadataMetrics); 16 17 // Interface for recording metrics from UnsentLogStore. 18 class UnsentLogStoreMetrics { 19 public: 20 // Used to produce a histogram that keeps track of the status of recalling 21 // persisted per logs. 22 enum LogReadStatus { 23 RECALL_SUCCESS, // We were able to correctly recall a persisted log. 24 LIST_EMPTY, // Attempting to recall from an empty list. 25 LIST_SIZE_MISSING, // Failed to recover list size using GetAsInteger(). 26 LIST_SIZE_TOO_SMALL, // Too few elements in the list (less than 3). 27 LIST_SIZE_CORRUPTION, // List size is not as expected. 28 LOG_STRING_CORRUPTION, // Failed to recover log string using GetAsString(). 29 CHECKSUM_CORRUPTION, // Failed to verify checksum. 30 CHECKSUM_STRING_CORRUPTION, // Failed to recover checksum string using 31 // GetAsString(). 32 DECODE_FAIL, // Failed to decode log. 33 DEPRECATED_XML_PROTO_MISMATCH, // The XML and protobuf logs have 34 // inconsistent data. 35 END_RECALL_STATUS // Number of bins to use to create the histogram. 36 }; 37 38 UnsentLogStoreMetrics(); 39 40 UnsentLogStoreMetrics(const UnsentLogStoreMetrics&) = delete; 41 UnsentLogStoreMetrics& operator=(const UnsentLogStoreMetrics&) = delete; 42 43 virtual ~UnsentLogStoreMetrics(); 44 45 virtual void RecordLogReadStatus(LogReadStatus status); 46 47 virtual void RecordCompressionRatio(size_t compressed_size, 48 size_t original_size); 49 50 virtual void RecordDroppedLogSize(size_t size); 51 52 virtual void RecordDroppedLogsNum(int dropped_logs_num); 53 54 virtual void RecordLastUnsentLogMetadataMetrics(int unsent_samples_count, 55 int sent_samples_count, 56 int persisted_size_in_kb); 57 }; 58 59 } // namespace metrics 60 61 #endif // COMPONENTS_METRICS_UNSENT_LOG_STORE_METRICS_H_ 62