Skip to content

Commit ccf82b1

Browse files
authored
improved code more clean (#1511)
* improved code more clean Signed-off-by: chuanshuo <[email protected]> * improved code more clean Signed-off-by: chuanshuo <[email protected]> --------- Signed-off-by: chuanshuo <[email protected]>
1 parent 853c5de commit ccf82b1

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

prometheus/registry.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,16 +314,17 @@ func (r *Registry) Register(c Collector) error {
314314
if dimHash != desc.dimHash {
315315
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)
316316
}
317-
} else {
318-
// ...then check the new descriptors already seen.
319-
if dimHash, exists := newDimHashesByName[desc.fqName]; exists {
320-
if dimHash != desc.dimHash {
321-
return fmt.Errorf("descriptors reported by collector have inconsistent label names or help strings for the same fully-qualified name, offender is %s", desc)
322-
}
323-
} else {
324-
newDimHashesByName[desc.fqName] = desc.dimHash
317+
continue
318+
}
319+
320+
// ...then check the new descriptors already seen.
321+
if dimHash, exists := newDimHashesByName[desc.fqName]; exists {
322+
if dimHash != desc.dimHash {
323+
return fmt.Errorf("descriptors reported by collector have inconsistent label names or help strings for the same fully-qualified name, offender is %s", desc)
325324
}
325+
continue
326326
}
327+
newDimHashesByName[desc.fqName] = desc.dimHash
327328
}
328329
// A Collector yielding no Desc at all is considered unchecked.
329330
if len(newDescIDs) == 0 {

0 commit comments

Comments
 (0)