improved code more clean (#1511)
* improved code more clean Signed-off-by: chuanshuo <lilijreey@126.com> * improved code more clean Signed-off-by: chuanshuo <lilijreey@126.com> --------- Signed-off-by: chuanshuo <lilijreey@126.com>
This commit is contained in:
parent
853c5de11e
commit
ccf82b1854
|
@ -314,16 +314,17 @@ func (r *Registry) Register(c Collector) error {
|
||||||
if dimHash != desc.dimHash {
|
if dimHash != desc.dimHash {
|
||||||
return fmt.Errorf("a previously registered descriptor with the same fully-qualified name as %s has different label names or a different help string", desc)
|
return fmt.Errorf("a previously registered descriptor with the same fully-qualified name as %s has different label names or a different help string", desc)
|
||||||
}
|
}
|
||||||
} else {
|
continue
|
||||||
// ...then check the new descriptors already seen.
|
|
||||||
if dimHash, exists := newDimHashesByName[desc.fqName]; exists {
|
|
||||||
if dimHash != desc.dimHash {
|
|
||||||
return fmt.Errorf("descriptors reported by collector have inconsistent label names or help strings for the same fully-qualified name, offender is %s", desc)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newDimHashesByName[desc.fqName] = desc.dimHash
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ...then check the new descriptors already seen.
|
||||||
|
if dimHash, exists := newDimHashesByName[desc.fqName]; exists {
|
||||||
|
if dimHash != desc.dimHash {
|
||||||
|
return fmt.Errorf("descriptors reported by collector have inconsistent label names or help strings for the same fully-qualified name, offender is %s", desc)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
newDimHashesByName[desc.fqName] = desc.dimHash
|
||||||
}
|
}
|
||||||
// A Collector yielding no Desc at all is considered unchecked.
|
// A Collector yielding no Desc at all is considered unchecked.
|
||||||
if len(newDescIDs) == 0 {
|
if len(newDescIDs) == 0 {
|
||||||
|
|
Loading…
Reference in New Issue