blob: 052a6cad9cb09d60531b88634c21a3515290f1ca [file] [log] [blame]
Avi Drissman8ba1bad2022-09-13 19:22:361// Copyright 2016 The Chromium Authors
holte961fa392016-12-28 20:57:062// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Yue Ru Sun227e27bb2019-05-10 23:53:055#ifndef COMPONENTS_METRICS_UNSENT_LOG_STORE_METRICS_H_
6#define COMPONENTS_METRICS_UNSENT_LOG_STORE_METRICS_H_
holte961fa392016-12-28 20:57:067
Tao Baiafdf8dfd402020-06-06 03:38:018#include "base/feature_list.h"
Yue Ru Sun227e27bb2019-05-10 23:53:059#include "components/metrics/unsent_log_store.h"
holte961fa392016-12-28 20:57:0610
11namespace metrics {
12
Daniel Chengbe539e082022-10-03 01:26:0713// The feature to record the unsent log info metrics, refer to
14// UnsentLogStoreMetricsImpl::RecordLastUnsentLogMetadataMetrics.
15BASE_DECLARE_FEATURE(kRecordLastUnsentLogMetadataMetrics);
16
Yue Ru Sun227e27bb2019-05-10 23:53:0517// Interface for recording metrics from UnsentLogStore.
18class UnsentLogStoreMetrics {
holte961fa392016-12-28 20:57:0619 public:
holteade6fdf2017-02-23 02:42:3920 // 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 Baiafdf8dfd402020-06-06 03:38:0138 UnsentLogStoreMetrics();
Peter Boström09c01822021-09-20 22:43:2739
40 UnsentLogStoreMetrics(const UnsentLogStoreMetrics&) = delete;
41 UnsentLogStoreMetrics& operator=(const UnsentLogStoreMetrics&) = delete;
42
Tao Baiafdf8dfd402020-06-06 03:38:0143 virtual ~UnsentLogStoreMetrics();
holte961fa392016-12-28 20:57:0644
Tao Baiafdf8dfd402020-06-06 03:38:0145 virtual void RecordLogReadStatus(LogReadStatus status);
holte961fa392016-12-28 20:57:0646
Tao Baiafdf8dfd402020-06-06 03:38:0147 virtual void RecordCompressionRatio(size_t compressed_size,
48 size_t original_size);
holte961fa392016-12-28 20:57:0649
Tao Baiafdf8dfd402020-06-06 03:38:0150 virtual void RecordDroppedLogSize(size_t size);
holte961fa392016-12-28 20:57:0651
Tao Baiafdf8dfd402020-06-06 03:38:0152 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);
holte961fa392016-12-28 20:57:0657};
58
59} // namespace metrics
60
Yue Ru Sun227e27bb2019-05-10 23:53:0561#endif // COMPONENTS_METRICS_UNSENT_LOG_STORE_METRICS_H_