• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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 #include "components/metrics/structured/histogram_util.h"
6 
7 #include "base/metrics/histogram_functions.h"
8 #include "base/metrics/histogram_macros.h"
9 
10 namespace metrics::structured {
11 
LogInternalError(StructuredMetricsError error)12 void LogInternalError(StructuredMetricsError error) {
13   UMA_HISTOGRAM_ENUMERATION("UMA.StructuredMetrics.InternalError2", error);
14 }
15 
LogEventRecordingState(EventRecordingState state)16 void LogEventRecordingState(EventRecordingState state) {
17   UMA_HISTOGRAM_ENUMERATION("UMA.StructuredMetrics.EventRecordingState", state);
18 }
19 
LogNumEventsInUpload(const int num_events)20 void LogNumEventsInUpload(const int num_events) {
21   UMA_HISTOGRAM_COUNTS_1000("UMA.StructuredMetrics.NumEventsInUpload",
22                             num_events);
23 }
24 
LogKeyValidation(KeyValidationState state)25 void LogKeyValidation(KeyValidationState state) {
26   UMA_HISTOGRAM_ENUMERATION("UMA.StructuredMetrics.KeyValidationState", state);
27 }
28 
LogIsEventRecordedUsingMojo(bool used_mojo_api)29 void LogIsEventRecordedUsingMojo(bool used_mojo_api) {
30   UMA_HISTOGRAM_BOOLEAN("UMA.StructuredMetrics.EventsRecordedUsingMojo",
31                         used_mojo_api);
32 }
33 
LogNumEventsRecordedBeforeInit(int num_events)34 void LogNumEventsRecordedBeforeInit(int num_events) {
35   UMA_HISTOGRAM_COUNTS_100("UMA.StructuredMetrics.EventsRecordedBeforeInit",
36                            num_events);
37 }
38 
LogNumFilesPerExternalMetricsScan(int num_files)39 void LogNumFilesPerExternalMetricsScan(int num_files) {
40   base::UmaHistogramCounts1000(
41       "UMA.StructuredMetrics.NumFilesPerExternalMetricsScan", num_files);
42 }
43 
LogEventFileSizeKB(int64_t file_size_kb)44 void LogEventFileSizeKB(int64_t file_size_kb) {
45   base::UmaHistogramMemoryKB("UMA.StructuredMetrics.EventFileSize",
46                              file_size_kb);
47 }
LogEventSerializedSizeBytes(int64_t event_size_bytes)48 void LogEventSerializedSizeBytes(int64_t event_size_bytes) {
49   base::UmaHistogramCounts1000("UMA.StructuredMetrics.EventSerializedSize",
50                                event_size_bytes);
51 }
52 
LogUploadSizeBytes(int64_t upload_size_bytes)53 void LogUploadSizeBytes(int64_t upload_size_bytes) {
54   base::UmaHistogramCounts1000("UMA.StructuredMetrics.UploadSize",
55                                upload_size_bytes);
56 }
57 
LogExternalMetricsScanInUpload(int num_scans)58 void LogExternalMetricsScanInUpload(int num_scans) {
59   base::UmaHistogramExactLinear(
60       "UMA.StructuredMetrics.ExternalMetricScansPerUpload", num_scans, 10);
61 }
62 
63 }  // namespace metrics::structured
64