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

Side by Side 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, 6 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/metrics/metrics_log.h" 5 #include "components/metrics/metrics_log.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 24 matching lines...) Expand all
35 35
36 #if defined(OS_WIN) 36 #if defined(OS_WIN)
37 #include "base/win/current_module.h" 37 #include "base/win/current_module.h"
38 #endif 38 #endif
39 39
40 using base::SampleCountIterator; 40 using base::SampleCountIterator;
41 typedef variations::ActiveGroupId ActiveGroupId; 41 typedef variations::ActiveGroupId ActiveGroupId;
42 42
43 namespace metrics { 43 namespace metrics {
44 44
45 namespace internal {
46 // Maximum number of events before truncation.
47 extern const int kOmniboxEventLimit = 5000;
48 extern const int kUserActionEventLimit = 5000;
49 }
50
45 namespace { 51 namespace {
46 52
47 // Any id less than 16 bytes is considered to be a testing id. 53 // Any id less than 16 bytes is considered to be a testing id.
48 bool IsTestingID(const std::string& id) { 54 bool IsTestingID(const std::string& id) {
49 return id.size() < 16; 55 return id.size() < 16;
50 } 56 }
51 57
52 void WriteFieldTrials(const std::vector<ActiveGroupId>& field_trial_ids, 58 void WriteFieldTrials(const std::vector<ActiveGroupId>& field_trial_ids,
53 SystemProfileProto* system_profile) { 59 SystemProfileProto* system_profile) {
54 for (std::vector<ActiveGroupId>::const_iterator it = 60 for (std::vector<ActiveGroupId>::const_iterator it =
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 if (success) 322 if (success)
317 *app_version = system_profile->app_version(); 323 *app_version = system_profile->app_version();
318 return success; 324 return success;
319 } 325 }
320 326
321 void MetricsLog::CloseLog() { 327 void MetricsLog::CloseLog() {
322 DCHECK(!closed_); 328 DCHECK(!closed_);
323 closed_ = true; 329 closed_ = true;
324 } 330 }
325 331
332 void MetricsLog::TruncateEvents() {
333 DCHECK(!closed_);
334 if (uma_proto_.user_action_event_size() > internal::kUserActionEventLimit) {
335 UMA_HISTOGRAM_COUNTS_100000("UMA.TruncatedEvents.UserAction",
336 uma_proto_.user_action_event_size());
337 uma_proto_.mutable_user_action_event()->DeleteSubrange(
338 internal::kUserActionEventLimit,
339 uma_proto_.user_action_event_size() - internal::kUserActionEventLimit);
340 }
341
342 if (uma_proto_.omnibox_event_size() > internal::kOmniboxEventLimit) {
343 UMA_HISTOGRAM_COUNTS_100000("UMA.TruncatedEvents.Omnibox",
344 uma_proto_.omnibox_event_size());
345 uma_proto_.mutable_omnibox_event()->DeleteSubrange(
346 internal::kOmniboxEventLimit,
347 uma_proto_.omnibox_event_size() - internal::kOmniboxEventLimit);
348 }
349 }
350
326 void MetricsLog::GetEncodedLog(std::string* encoded_log) { 351 void MetricsLog::GetEncodedLog(std::string* encoded_log) {
327 DCHECK(closed_); 352 DCHECK(closed_);
328 uma_proto_.SerializeToString(encoded_log); 353 uma_proto_.SerializeToString(encoded_log);
329 } 354 }
330 355
331 } // namespace metrics 356 } // namespace metrics
OLDNEW
« 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