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

Unified Diff: tracing/tracing/metrics/metric_registry.html

Issue 2656493002: Register metric Histogram names. (Closed)
Patch Set: rebase Created 3 years, 10 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 | « tracing/tracing/metrics/metric_map_function.html ('k') | tracing/tracing/metrics/metric_registry_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/metrics/metric_registry.html
diff --git a/tracing/tracing/metrics/metric_registry.html b/tracing/tracing/metrics/metric_registry.html
index 7538d743805c544092efd2b92c62bd1c5755ad7a..ced5222b04a348b772338670c2db1d3f0e358744 100644
--- a/tracing/tracing/metrics/metric_registry.html
+++ b/tracing/tracing/metrics/metric_registry.html
@@ -20,13 +20,31 @@ tr.exportTo('tr.metrics', function() {
MetricRegistry.addEventListener('will-register', function(e) {
var metric = e.typeInfo.constructor;
- if (!(metric instanceof Function))
+ var metadata = e.typeInfo.metadata;
+
+ if (!(metric instanceof Function)) {
throw new Error('Metrics must be functions');
+ }
if (metric.length < 2) {
throw new Error('Metrics take a HistogramSet and a Model and ' +
'optionally an options dictionary');
}
+
+ if (!(metadata.histogramNames instanceof Set)) {
+ throw new Error('Metrics must register the set of Histogram names ' +
+ 'that they may produce');
+ }
+
+ for (var typeInfo of MetricRegistry.getAllRegisteredTypeInfos()) {
+ for (var name of metadata.histogramNames) {
+ if (typeInfo.metadata.histogramNames.has(name)) {
+ throw new Error('Multiple metrics cannot produce Histograms ' +
+ 'with the same name: ' + name + ' ' + metric.name + ' ' +
+ typeInfo.constructor.name);
+ }
+ }
+ }
});
return {
« no previous file with comments | « tracing/tracing/metrics/metric_map_function.html ('k') | tracing/tracing/metrics/metric_registry_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698