diff --git a/prometheus/registry.go b/prometheus/registry.go index cb108f5..65ea520 100644 --- a/prometheus/registry.go +++ b/prometheus/registry.go @@ -33,8 +33,8 @@ import ( dto "github.com/prometheus/client_model/go" - "compress/gzip" "code.google.com/p/goprotobuf/proto" + "compress/gzip" "github.com/prometheus/client_golang/_vendor/goautoneg" "github.com/prometheus/client_golang/model" @@ -424,6 +424,12 @@ func (r *registry) writePB(w io.Writer, writeEncoded encoder) (int, error) { } r.mtx.RUnlock() + // Drain metricChan in case of premature return. + defer func() { + for range metricChan { + } + }() + // Gather. for metric := range metricChan { // This could be done concurrently, too, but it required locking