From d66557ae597b97ad515ff6a5b2fb8d055323b7f8 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Wed, 10 Dec 2014 20:05:35 -0500 Subject: [PATCH] Register process and go collectors by default --- prometheus/registry.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/prometheus/registry.go b/prometheus/registry.go index 65ea520..8485f9a 100644 --- a/prometheus/registry.go +++ b/prometheus/registry.go @@ -21,12 +21,14 @@ package prometheus import ( "bytes" + "compress/gzip" "errors" "fmt" "hash/fnv" "io" "net/http" "net/url" + "os" "sort" "strings" "sync" @@ -34,7 +36,6 @@ import ( dto "github.com/prometheus/client_model/go" "code.google.com/p/goprotobuf/proto" - "compress/gzip" "github.com/prometheus/client_golang/_vendor/goautoneg" "github.com/prometheus/client_golang/model" @@ -42,7 +43,7 @@ import ( ) var ( - defRegistry = newRegistry() + defRegistry = newDefaultRegistry() errAlreadyReg = errors.New("duplicate metrics collector registration attempted") ) @@ -643,6 +644,13 @@ func newRegistry() *registry { } } +func newDefaultRegistry() *registry { + r := newRegistry() + r.Register(NewProcessCollector(os.Getpid(), "")) + r.Register(NewGoCollector()) + return r +} + func chooseEncoder(req *http.Request) (encoder, string) { accepts := goautoneg.ParseAccept(req.Header.Get(acceptHeader)) for _, accept := range accepts {