unsent_log_store_metrics.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_METRICS_UNSENT_LOG_STORE_METRICS_H_
  5. #define COMPONENTS_METRICS_UNSENT_LOG_STORE_METRICS_H_
  6. #include "base/feature_list.h"
  7. #include "components/metrics/unsent_log_store.h"
  8. namespace metrics {
  9. // Interface for recording metrics from UnsentLogStore.
  10. class UnsentLogStoreMetrics {
  11. public:
  12. // Used to produce a histogram that keeps track of the status of recalling
  13. // persisted per logs.
  14. enum LogReadStatus {
  15. RECALL_SUCCESS, // We were able to correctly recall a persisted log.
  16. LIST_EMPTY, // Attempting to recall from an empty list.
  17. LIST_SIZE_MISSING, // Failed to recover list size using GetAsInteger().
  18. LIST_SIZE_TOO_SMALL, // Too few elements in the list (less than 3).
  19. LIST_SIZE_CORRUPTION, // List size is not as expected.
  20. LOG_STRING_CORRUPTION, // Failed to recover log string using GetAsString().
  21. CHECKSUM_CORRUPTION, // Failed to verify checksum.
  22. CHECKSUM_STRING_CORRUPTION, // Failed to recover checksum string using
  23. // GetAsString().
  24. DECODE_FAIL, // Failed to decode log.
  25. DEPRECATED_XML_PROTO_MISMATCH, // The XML and protobuf logs have
  26. // inconsistent data.
  27. END_RECALL_STATUS // Number of bins to use to create the histogram.
  28. };
  29. UnsentLogStoreMetrics();
  30. UnsentLogStoreMetrics(const UnsentLogStoreMetrics&) = delete;
  31. UnsentLogStoreMetrics& operator=(const UnsentLogStoreMetrics&) = delete;
  32. virtual ~UnsentLogStoreMetrics();
  33. virtual void RecordLogReadStatus(LogReadStatus status);
  34. virtual void RecordCompressionRatio(size_t compressed_size,
  35. size_t original_size);
  36. virtual void RecordDroppedLogSize(size_t size);
  37. virtual void RecordDroppedLogsNum(int dropped_logs_num);
  38. virtual void RecordLastUnsentLogMetadataMetrics(int unsent_samples_count,
  39. int sent_samples_count,
  40. int persisted_size_in_kb);
  41. // The feature to record the unsent log info metrics, refer to
  42. // UnsentLogStoreMetricsImpl::RecordLastUnsentLogMetadataMetrics.
  43. static const base::Feature kRecordLastUnsentLogMetadataMetrics;
  44. };
  45. } // namespace metrics
  46. #endif // COMPONENTS_METRICS_UNSENT_LOG_STORE_METRICS_H_