forked from mirror/client_golang
Merge pull request #40 from prometheus/drain-collect-channel
Drain collector channel when returning prematurely.
This commit is contained in:
commit
2657498a2f
|
@ -1,7 +1,7 @@
|
|||
language: go
|
||||
|
||||
go:
|
||||
- 1.2.1
|
||||
- 1.4
|
||||
|
||||
script:
|
||||
- make -f Makefile
|
||||
|
|
5
Makefile
5
Makefile
|
@ -18,7 +18,7 @@ MAC_OS_X_VERSION ?= 10.8
|
|||
|
||||
BUILD_PATH = $(PWD)/.build
|
||||
|
||||
export GO_VERSION = 1.2.1
|
||||
export GO_VERSION = 1.4
|
||||
export GOOS = $(subst Darwin,darwin,$(subst Linux,linux,$(OS)))
|
||||
|
||||
ifeq ($(GOOS),darwin)
|
||||
|
@ -29,6 +29,7 @@ endif
|
|||
|
||||
export GOARCH = $(subst x86_64,amd64,$(ARCH))
|
||||
export GOPKG = go$(GO_VERSION).$(GOOS)-$(GOARCH)$(RELEASE_SUFFIX).tar.gz
|
||||
export GOURL = http://golang.org/dl
|
||||
export GOROOT = $(BUILD_PATH)/root/go
|
||||
export GOPATH = $(BUILD_PATH)/root/gopath
|
||||
export GOCC = $(GOROOT)/bin/go
|
||||
|
@ -57,7 +58,7 @@ $(BUILD_PATH)/root: $(BUILD_PATH)
|
|||
mkdir -vp $(BUILD_PATH)/root
|
||||
|
||||
$(BUILD_PATH)/cache/$(GOPKG): $(BUILD_PATH)/cache
|
||||
curl -o $@ http://go.googlecode.com/files/$(GOPKG)
|
||||
curl -o $@ -L $(GOURL)/$(GOPKG)
|
||||
|
||||
$(GOCC): $(BUILD_PATH)/root $(BUILD_PATH)/cache/$(GOPKG)
|
||||
tar -C $(BUILD_PATH)/root -xzf $(BUILD_PATH)/cache/$(GOPKG)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue