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

Side by Side Diff: components/ntp_snippets/content_suggestions_metrics.cc

Issue 2619203007: Log suggestion scores in 10 discrete buckets. (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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/ntp_snippets/content_suggestions_metrics.h" 5 #include "components/ntp_snippets/content_suggestions_metrics.h"
6 6
7 #include <cmath>
7 #include <string> 8 #include <string>
8 #include <type_traits> 9 #include <type_traits>
9 10
10 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
11 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
12 #include "base/metrics/user_metrics.h" 13 #include "base/metrics/user_metrics.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "base/template_util.h" 15 #include "base/template_util.h"
15 16
16 namespace ntp_snippets { 17 namespace ntp_snippets {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 void UmaHistogramAge(const std::string& name, const base::TimeDelta& value) { 162 void UmaHistogramAge(const std::string& name, const base::TimeDelta& value) {
162 base::Histogram::FactoryTimeGet( 163 base::Histogram::FactoryTimeGet(
163 name, base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(7), 100, 164 name, base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(7), 100,
164 base::HistogramBase::kUmaTargetedHistogramFlag) 165 base::HistogramBase::kUmaTargetedHistogramFlag)
165 ->AddTime(value); 166 ->AddTime(value);
166 } 167 }
167 168
168 // This corresponds to UMA_HISTOGRAM_CUSTOM_COUNTS (with min/max appropriate 169 // This corresponds to UMA_HISTOGRAM_CUSTOM_COUNTS (with min/max appropriate
169 // for the score of suggestions) for use with dynamic histogram names. 170 // for the score of suggestions) for use with dynamic histogram names.
170 void UmaHistogramScore(const std::string& name, float value) { 171 void UmaHistogramScore(const std::string& name, float value) {
171 base::Histogram::FactoryGet(name, 1, 100000, 50, 172 // Scores are typically reported in a range of [0,1]. As UMA does not support
173 // floats, we put them on a discrete scale of [1,10]. We keep the extra bucket
jkrcal 2017/01/10 19:31:47 nit: Could you expand the comment, e.g. "For insta
tschumann 2017/01/12 12:25:31 Done.
174 // for unexpected over-flows.
175 base::Histogram::FactoryGet(name, 1, 11, 12,
jkrcal 2017/01/10 19:31:47 I think you should use LinearHistogram, instead. H
tschumann 2017/01/12 12:25:31 Apparently, we need to create a new histogram for
jkrcal 2017/01/12 15:13:10 Acknowledged.
172 base::HistogramBase::kUmaTargetedHistogramFlag) 176 base::HistogramBase::kUmaTargetedHistogramFlag)
173 ->Add(value); 177 ->Add(ceil(value*10));
174 } 178 }
175 179
176 void LogCategoryHistogramEnumeration(const char* base_name, 180 void LogCategoryHistogramEnumeration(const char* base_name,
177 Category category, 181 Category category,
178 int value, 182 int value,
179 int boundary_value) { 183 int boundary_value) {
180 std::string name = GetCategoryHistogramName(base_name, category); 184 std::string name = GetCategoryHistogramName(base_name, category);
181 // Since the histogram name is dynamic, we can't use the regular macro. 185 // Since the histogram name is dynamic, we can't use the regular macro.
182 UmaHistogramEnumeration(name, value, boundary_value); 186 UmaHistogramEnumeration(name, value, boundary_value);
183 } 187 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 367 }
364 368
365 void OnCategoryDismissed(Category category) { 369 void OnCategoryDismissed(Category category) {
366 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed, 370 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed,
367 static_cast<int>(GetHistogramCategory(category)), 371 static_cast<int>(GetHistogramCategory(category)),
368 static_cast<int>(HistogramCategories::COUNT)); 372 static_cast<int>(HistogramCategories::COUNT));
369 } 373 }
370 374
371 } // namespace metrics 375 } // namespace metrics
372 } // namespace ntp_snippets 376 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698