Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using the global prometheus registry #1460

Merged
merged 3 commits into from
May 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions http/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package http
import (
"fmt"
"net/http"
"os"

"github.com/google/cadvisor/api"
"github.com/google/cadvisor/healthz"
Expand All @@ -30,6 +31,7 @@ import (
auth "github.com/abbot/go-http-auth"
"github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

func RegisterHandlers(mux httpmux.Mux, containerManager manager.Manager, httpAuthFile, httpAuthRealm, httpDigestFile, httpDigestRealm string) error {
Expand All @@ -54,7 +56,7 @@ func RegisterHandlers(mux httpmux.Mux, containerManager manager.Manager, httpAut
// Redirect / to containers page.
mux.Handle("/", http.RedirectHandler(pages.ContainersPage, http.StatusTemporaryRedirect))

var authenticated bool = false
var authenticated bool

// Setup the authenticator object
if httpAuthFile != "" {
Expand Down Expand Up @@ -89,13 +91,16 @@ func RegisterHandlers(mux httpmux.Mux, containerManager manager.Manager, httpAut
return nil
}

// RegisterPrometheusHandler creates a new PrometheusCollector, registers it
// on the global registry and configures the provided HTTP mux to handle the
// given Prometheus endpoint.
// RegisterPrometheusHandler creates a new PrometheusCollector and configures
// the provided HTTP mux to handle the given Prometheus endpoint.
func RegisterPrometheusHandler(mux httpmux.Mux, containerManager manager.Manager, prometheusEndpoint string, f metrics.ContainerLabelsFunc) {
collector := metrics.NewPrometheusCollector(containerManager, f)
prometheus.MustRegister(collector)
mux.Handle(prometheusEndpoint, prometheus.Handler())
r := prometheus.NewRegistry()
r.MustRegister(
metrics.NewPrometheusCollector(containerManager, f),
prometheus.NewGoCollector(),
prometheus.NewProcessCollector(os.Getpid(), ""),
)
mux.Handle(prometheusEndpoint, promhttp.HandlerFor(r, promhttp.HandlerOpts{}))
}

func staticHandlerNoAuth(w http.ResponseWriter, r *http.Request) {
Expand Down
5 changes: 0 additions & 5 deletions vendor/github.com/prometheus/client_golang/NOTICE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 1 addition & 53 deletions vendor/github.com/prometheus/client_golang/prometheus/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 26 additions & 26 deletions vendor/github.com/prometheus/client_golang/prometheus/collector.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 13 additions & 24 deletions vendor/github.com/prometheus/client_golang/prometheus/counter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading