Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Unified Diff: components/metrics/metrics_log.cc

Issue 2910023003: Change the logic for discarding all non-histogram logs because of actions/omnibox events to truncat… (Closed)
Patch Set: today extension Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/metrics/metrics_log.h ('k') | components/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/metrics_log.cc
diff --git a/components/metrics/metrics_log.cc b/components/metrics/metrics_log.cc
index ac35ce396a32a8f06f1a7a7d913953cbb161e290..a9f2fe6109dac4aa24c288d6536dd055a0e4cb18 100644
--- a/components/metrics/metrics_log.cc
+++ b/components/metrics/metrics_log.cc
@@ -42,6 +42,12 @@ typedef variations::ActiveGroupId ActiveGroupId;
namespace metrics {
+namespace internal {
+// Maximum number of events before truncation.
+extern const int kOmniboxEventLimit = 5000;
+extern const int kUserActionEventLimit = 5000;
+}
+
namespace {
// Any id less than 16 bytes is considered to be a testing id.
@@ -323,6 +329,25 @@ void MetricsLog::CloseLog() {
closed_ = true;
}
+void MetricsLog::TruncateEvents() {
+ DCHECK(!closed_);
+ if (uma_proto_.user_action_event_size() > internal::kUserActionEventLimit) {
+ UMA_HISTOGRAM_COUNTS_100000("UMA.TruncatedEvents.UserAction",
+ uma_proto_.user_action_event_size());
+ uma_proto_.mutable_user_action_event()->DeleteSubrange(
+ internal::kUserActionEventLimit,
+ uma_proto_.user_action_event_size() - internal::kUserActionEventLimit);
+ }
+
+ if (uma_proto_.omnibox_event_size() > internal::kOmniboxEventLimit) {
+ UMA_HISTOGRAM_COUNTS_100000("UMA.TruncatedEvents.Omnibox",
+ uma_proto_.omnibox_event_size());
+ uma_proto_.mutable_omnibox_event()->DeleteSubrange(
+ internal::kOmniboxEventLimit,
+ uma_proto_.omnibox_event_size() - internal::kOmniboxEventLimit);
+ }
+}
+
void MetricsLog::GetEncodedLog(std::string* encoded_log) {
DCHECK(closed_);
uma_proto_.SerializeToString(encoded_log);
« no previous file with comments | « components/metrics/metrics_log.h ('k') | components/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698