Drain collector channel when returning prematurely.
This commit is contained in:
parent
deef44ca73
commit
7fcb2c594a
|
@ -33,8 +33,8 @@ import (
|
||||||
|
|
||||||
dto "github.com/prometheus/client_model/go"
|
dto "github.com/prometheus/client_model/go"
|
||||||
|
|
||||||
"compress/gzip"
|
|
||||||
"code.google.com/p/goprotobuf/proto"
|
"code.google.com/p/goprotobuf/proto"
|
||||||
|
"compress/gzip"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/_vendor/goautoneg"
|
"github.com/prometheus/client_golang/_vendor/goautoneg"
|
||||||
"github.com/prometheus/client_golang/model"
|
"github.com/prometheus/client_golang/model"
|
||||||
|
@ -424,6 +424,12 @@ func (r *registry) writePB(w io.Writer, writeEncoded encoder) (int, error) {
|
||||||
}
|
}
|
||||||
r.mtx.RUnlock()
|
r.mtx.RUnlock()
|
||||||
|
|
||||||
|
// Drain metricChan in case of premature return.
|
||||||
|
defer func() {
|
||||||
|
for range metricChan {
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// Gather.
|
// Gather.
|
||||||
for metric := range metricChan {
|
for metric := range metricChan {
|
||||||
// This could be done concurrently, too, but it required locking
|
// This could be done concurrently, too, but it required locking
|
||||||
|
|
Loading…
Reference in New Issue