mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-23 12:30:46 +01:00
Merge pull request #2808 from ToMe25/fix_error_total_disabling
Fix promhttp_metric_handler_errors_total being always active
This commit is contained in:
commit
0f6a4d8c39
@ -123,7 +123,10 @@ func (h *handler) innerHandler(filters ...string) (http.Handler, error) {
|
||||
if err := r.Register(nc); err != nil {
|
||||
return nil, fmt.Errorf("couldn't register node collector: %s", err)
|
||||
}
|
||||
handler := promhttp.HandlerFor(
|
||||
|
||||
var handler http.Handler
|
||||
if h.includeExporterMetrics {
|
||||
handler = promhttp.HandlerFor(
|
||||
prometheus.Gatherers{h.exporterMetricsRegistry, r},
|
||||
promhttp.HandlerOpts{
|
||||
ErrorLog: stdlog.New(log.NewStdlibAdapter(level.Error(h.logger)), "", 0),
|
||||
@ -132,13 +135,22 @@ func (h *handler) innerHandler(filters ...string) (http.Handler, error) {
|
||||
Registry: h.exporterMetricsRegistry,
|
||||
},
|
||||
)
|
||||
if h.includeExporterMetrics {
|
||||
// Note that we have to use h.exporterMetricsRegistry here to
|
||||
// use the same promhttp metrics for all expositions.
|
||||
handler = promhttp.InstrumentMetricHandler(
|
||||
h.exporterMetricsRegistry, handler,
|
||||
)
|
||||
} else {
|
||||
handler = promhttp.HandlerFor(
|
||||
r,
|
||||
promhttp.HandlerOpts{
|
||||
ErrorLog: stdlog.New(log.NewStdlibAdapter(level.Error(h.logger)), "", 0),
|
||||
ErrorHandling: promhttp.ContinueOnError,
|
||||
MaxRequestsInFlight: h.maxRequests,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return handler, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user