From 2bdf2152dd5ddba5248dfe54431c8fd3fa4b81da Mon Sep 17 00:00:00 2001 From: Suyash Date: Sat, 6 Aug 2016 17:16:39 +0530 Subject: [PATCH] registry: track instance name lengths --- registry.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/registry.go b/registry.go index 1400e86..85b42b9 100644 --- a/registry.go +++ b/registry.go @@ -108,7 +108,7 @@ func (r *PCPRegistry) ValuesCount() int { return r.valueCount } // StringCount returns the number of strings in the registry func (r *PCPRegistry) StringCount() int { if r.version2 { - return r.stringcount + r.MetricCount() + return r.stringcount + r.MetricCount() + r.InstanceCount() } return r.stringcount @@ -148,6 +148,14 @@ func (r *PCPRegistry) AddInstanceDomain(indom InstanceDomain) error { r.instanceDomains[indom.Name()] = indom.(*PCPInstanceDomain) r.instanceCount += indom.InstanceCount() + if !r.version2 { + for _, v := range indom.Instances() { + if len(v) > MaxV1MetricNameLength { + r.version2 = true + } + } + } + log.WithFields(logrus.Fields{ "prefix": "registry", "name": indom.Name(),