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 { |