Update startup code to match changes in dependencies

This commit is contained in:
Bryan Boreham
2020-03-10 19:40:16 +00:00
parent 4e624492e9
commit b121950acf
2 changed files with 16 additions and 7 deletions

View File

@@ -16,6 +16,7 @@ import (
"github.com/goji/httpauth"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
"github.com/tylerb/graceful"
@@ -61,7 +62,7 @@ func router(collector app.Collector, controlRouter app.ControlRouter, pipeRouter
// We pull in the http.DefaultServeMux to get the pprof routes
router.PathPrefix("/debug/pprof").Handler(http.DefaultServeMux)
router.Path("/metrics").Handler(prometheus.Handler())
router.Path("/metrics").Handler(promhttp.Handler())
app.RegisterReportPostHandler(collector, router)
app.RegisterControlRoutes(router, controlRouter)
@@ -217,8 +218,12 @@ func appMain(flags appFlags) {
registerAppMetricsOnce.Do(registerAppMetrics)
traceCloser := tracing.NewFromEnv(fmt.Sprintf("scope-%s", flags.serviceName))
defer traceCloser.Close()
traceCloser, err := tracing.NewFromEnv(fmt.Sprintf("scope-%s", flags.serviceName))
if err != nil {
log.Infof("Tracing not initialized: %s", err)
} else {
defer traceCloser.Close()
}
defer log.Info("app exiting")
rand.Seed(time.Now().UnixNano())

View File

@@ -14,7 +14,7 @@ import (
"github.com/armon/go-metrics"
metrics_prom "github.com/armon/go-metrics/prometheus"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
"github.com/weaveworks/common/logging"
@@ -87,7 +87,7 @@ func checkNewScopeVersion(flags probeFlags) {
func maybeExportProfileData(flags probeFlags) {
if flags.httpListen != "" {
go func() {
http.Handle("/metrics", prometheus.Handler())
http.Handle("/metrics", promhttp.Handler())
log.Infof("Profiling data being exported to %s", flags.httpListen)
log.Infof("go tool pprof http://%s/debug/pprof/{profile,heap,block}", flags.httpListen)
log.Infof("Profiling endpoint %s terminated: %v", flags.httpListen, http.ListenAndServe(flags.httpListen, nil))
@@ -106,8 +106,12 @@ func probeMain(flags probeFlags, targets []appclient.Target) {
log.Infof("Basic authentication disabled")
}
traceCloser := tracing.NewFromEnv("scope-probe")
defer traceCloser.Close()
traceCloser, err := tracing.NewFromEnv("scope-probe")
if err != nil {
log.Infof("Tracing not initialized: %s", err)
} else {
defer traceCloser.Close()
}
cfg := &metrics.Config{
ServiceName: "scope-probe",