Skip to content
Closed
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
9 changes: 2 additions & 7 deletions go/stats/prometheusbackend/prometheusbackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import (
"expvar"
"net/http"
"strings"
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"vitess.io/vitess/go/stats"
"vitess.io/vitess/go/vt/logutil"
)

// PromBackend implements PullBackend using Prometheus as the backing metrics storage.
Expand All @@ -18,15 +16,13 @@ type PromBackend struct {
}

var (
be PromBackend
logUnsupported *logutil.ThrottledLogger
be PromBackend
)

// Init initializes the Prometheus be with the given namespace.
func Init(namespace string) {
http.Handle("/metrics", promhttp.Handler())
be.namespace = namespace
logUnsupported = logutil.NewThrottledLogger("PrometheusUnsupportedMetricType", 1*time.Minute)
stats.Register(be.publishPrometheusMetric)
}

Expand Down Expand Up @@ -67,9 +63,8 @@ func (be PromBackend) publishPrometheusMetric(name string, v expvar.Var) {
newMultiTimingsCollector(st, be.buildPromName(name))
case *stats.Histogram:
newHistogramCollector(st, be.buildPromName(name))
default:
logUnsupported.Infof("Not exporting to Prometheus an unsupported metric type of %T: %s", st, name)
}
// All other types of metrics are not currently collected and published to Prometheus
}

// buildPromName specifies the namespace as a prefix to the metric name
Expand Down