Skip to content

Commit 7c46c15

Browse files
authored
Clarify documentation around what constructors do (#1125)
The wording of the documentation is slightly misleading. Before this commit, it says that the returned collectors are "already registered". This could be interpreted in two ways, one could think that promauto keeps some sort of cache of already registered Collectors that are returned by this package, and the other way is that the Collectors constructed are registered before being returned. What is actually happening is the latter, and the wording after this PR leaves no room to think that the former could be the case. Signed-off-by: Rafael Franco <[email protected]> Signed-off-by: Rafael Franco <[email protected]>
1 parent 83d56b1 commit 7c46c15

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

prometheus/promauto/auto.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
// Package promauto provides alternative constructors for the fundamental
1515
// Prometheus metric types and their …Vec and …Func variants. The difference to
1616
// their counterparts in the prometheus package is that the promauto
17-
// constructors return Collectors that are already registered with a
18-
// registry. There are two sets of constructors. The constructors in the first
19-
// set are top-level functions, while the constructors in the other set are
20-
// methods of the Factory type. The top-level function return Collectors
21-
// registered with the global registry (prometheus.DefaultRegisterer), while the
22-
// methods return Collectors registered with the registry the Factory was
23-
// constructed with. All constructors panic if the registration fails.
17+
// constructors register the Collectors with a registry before returning them.
18+
// There are two sets of constructors. The constructors in the first set are
19+
// top-level functions, while the constructors in the other set are methods of
20+
// the Factory type. The top-level function return Collectors registered with
21+
// the global registry (prometheus.DefaultRegisterer), while the methods return
22+
// Collectors registered with the registry the Factory was constructed with. All
23+
// constructors panic if the registration fails.
2424
//
2525
// The following example is a complete program to create a histogram of normally
2626
// distributed random numbers from the math/rand package:

0 commit comments

Comments
 (0)