Register process and go collectors by default

This commit is contained in:
Tobias Schmidt 2014-12-10 20:05:35 -05:00
parent dbd48d666b
commit d66557ae59
1 changed files with 10 additions and 2 deletions

View File

@ -21,12 +21,14 @@ package prometheus
import ( import (
"bytes" "bytes"
"compress/gzip"
"errors" "errors"
"fmt" "fmt"
"hash/fnv" "hash/fnv"
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
"os"
"sort" "sort"
"strings" "strings"
"sync" "sync"
@ -34,7 +36,6 @@ import (
dto "github.com/prometheus/client_model/go" dto "github.com/prometheus/client_model/go"
"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"
@ -42,7 +43,7 @@ import (
) )
var ( var (
defRegistry = newRegistry() defRegistry = newDefaultRegistry()
errAlreadyReg = errors.New("duplicate metrics collector registration attempted") 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) { func chooseEncoder(req *http.Request) (encoder, string) {
accepts := goautoneg.ParseAccept(req.Header.Get(acceptHeader)) accepts := goautoneg.ParseAccept(req.Header.Get(acceptHeader))
for _, accept := range accepts { for _, accept := range accepts {