Avi Drissman | 8ba1bad | 2022-09-13 19:22:36 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors |
holte | 961fa39 | 2016-12-28 20:57:06 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Yue Ru Sun | 227e27bb | 2019-05-10 23:53:05 | [diff] [blame] | 5 | #ifndef COMPONENTS_METRICS_UNSENT_LOG_STORE_METRICS_H_ |
| 6 | #define COMPONENTS_METRICS_UNSENT_LOG_STORE_METRICS_H_ |
holte | 961fa39 | 2016-12-28 20:57:06 | [diff] [blame] | 7 | |
Tao Bai | afdf8dfd40 | 2020-06-06 03:38:01 | [diff] [blame] | 8 | #include "base/feature_list.h" |
Yue Ru Sun | 227e27bb | 2019-05-10 23:53:05 | [diff] [blame] | 9 | #include "components/metrics/unsent_log_store.h" |
holte | 961fa39 | 2016-12-28 20:57:06 | [diff] [blame] | 10 | |
| 11 | namespace metrics { |
| 12 | |
Daniel Cheng | be539e08 | 2022-10-03 01:26:07 | [diff] [blame] | 13 | // The feature to record the unsent log info metrics, refer to |
| 14 | // UnsentLogStoreMetricsImpl::RecordLastUnsentLogMetadataMetrics. |
| 15 | BASE_DECLARE_FEATURE(kRecordLastUnsentLogMetadataMetrics); |
| 16 | |
Yue Ru Sun | 227e27bb | 2019-05-10 23:53:05 | [diff] [blame] | 17 | // Interface for recording metrics from UnsentLogStore. |
| 18 | class UnsentLogStoreMetrics { |
holte | 961fa39 | 2016-12-28 20:57:06 | [diff] [blame] | 19 | public: |
holte | ade6fdf | 2017-02-23 02:42:39 | [diff] [blame] | 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 | |
Tao Bai | afdf8dfd40 | 2020-06-06 03:38:01 | [diff] [blame] | 38 | UnsentLogStoreMetrics(); |
Peter Boström | 09c0182 | 2021-09-20 22:43:27 | [diff] [blame] | 39 | |
| 40 | UnsentLogStoreMetrics(const UnsentLogStoreMetrics&) = delete; |
| 41 | UnsentLogStoreMetrics& operator=(const UnsentLogStoreMetrics&) = delete; |
| 42 | |
Tao Bai | afdf8dfd40 | 2020-06-06 03:38:01 | [diff] [blame] | 43 | virtual ~UnsentLogStoreMetrics(); |
holte | 961fa39 | 2016-12-28 20:57:06 | [diff] [blame] | 44 | |
Tao Bai | afdf8dfd40 | 2020-06-06 03:38:01 | [diff] [blame] | 45 | virtual void RecordLogReadStatus(LogReadStatus status); |
holte | 961fa39 | 2016-12-28 20:57:06 | [diff] [blame] | 46 | |
Tao Bai | afdf8dfd40 | 2020-06-06 03:38:01 | [diff] [blame] | 47 | virtual void RecordCompressionRatio(size_t compressed_size, |
| 48 | size_t original_size); |
holte | 961fa39 | 2016-12-28 20:57:06 | [diff] [blame] | 49 | |
Tao Bai | afdf8dfd40 | 2020-06-06 03:38:01 | [diff] [blame] | 50 | virtual void RecordDroppedLogSize(size_t size); |
holte | 961fa39 | 2016-12-28 20:57:06 | [diff] [blame] | 51 | |
Tao Bai | afdf8dfd40 | 2020-06-06 03:38:01 | [diff] [blame] | 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); |
holte | 961fa39 | 2016-12-28 20:57:06 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | } // namespace metrics |
| 60 | |
Yue Ru Sun | 227e27bb | 2019-05-10 23:53:05 | [diff] [blame] | 61 | #endif // COMPONENTS_METRICS_UNSENT_LOG_STORE_METRICS_H_ |