Skip to content

Commit 37c26ed

Browse files
authored
Merge pull request #821 from prometheus/beorn7/multierror
Be more explicit about the multi-line properties of MultiError
2 parents fd6d368 + 34ca120 commit 37c26ed

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Diff for: prometheus/promhttp/http.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,12 @@ type Logger interface {
303303
// HandlerOpts specifies options how to serve metrics via an http.Handler. The
304304
// zero value of HandlerOpts is a reasonable default.
305305
type HandlerOpts struct {
306-
// ErrorLog specifies an optional logger for errors collecting and
307-
// serving metrics. If nil, errors are not logged at all.
306+
// ErrorLog specifies an optional Logger for errors collecting and
307+
// serving metrics. If nil, errors are not logged at all. Note that the
308+
// type of a reported error is often prometheus.MultiError, which
309+
// formats into a multi-line error string. If you want to avoid the
310+
// latter, create a Logger implementation that detects a
311+
// prometheus.MultiError and formats the contained errors into one line.
308312
ErrorLog Logger
309313
// ErrorHandling defines how errors are handled. Note that errors are
310314
// logged regardless of the configured ErrorHandling provided ErrorLog

Diff for: prometheus/registry.go

+2
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ func (err AlreadyRegisteredError) Error() string {
215215
// by a Gatherer to report multiple errors during MetricFamily gathering.
216216
type MultiError []error
217217

218+
// Error formats the contained errors as a bullet point list, preceded by the
219+
// total number of errors. Note that this results in a multi-line string.
218220
func (errs MultiError) Error() string {
219221
if len(errs) == 0 {
220222
return ""

0 commit comments

Comments
 (0)