chore(telemetry): move telemetry into its own package

pull/11347/head
Chris Goller 2019-01-18 18:57:26 -06:00
parent b3161b0927
commit e690f4bfb3
4 changed files with 15 additions and 13 deletions

View File

@ -25,7 +25,7 @@ import (
"github.com/influxdata/influxdb/kit/prom"
influxlogger "github.com/influxdata/influxdb/logger"
"github.com/influxdata/influxdb/nats"
promusage "github.com/influxdata/influxdb/prometheus"
infprom "github.com/influxdata/influxdb/prometheus"
"github.com/influxdata/influxdb/proto"
"github.com/influxdata/influxdb/query"
pcontrol "github.com/influxdata/influxdb/query/control"
@ -38,6 +38,7 @@ import (
taskbolt "github.com/influxdata/influxdb/task/backend/bolt"
"github.com/influxdata/influxdb/task/backend/coordinator"
taskexecutor "github.com/influxdata/influxdb/task/backend/executor"
"github.com/influxdata/influxdb/telemetry"
_ "github.com/influxdata/influxdb/tsdb/tsi1" // needed for tsi1
_ "github.com/influxdata/influxdb/tsdb/tsm1" // needed for tsm1
"github.com/influxdata/influxdb/vault"
@ -268,7 +269,7 @@ func (m *Launcher) run(ctx context.Context) (err error) {
m.reg = prom.NewRegistry()
m.reg.MustRegister(
prometheus.NewGoCollector(),
promusage.NewInfluxCollector(m.boltClient, m.BuildInfo),
infprom.NewInfluxCollector(m.boltClient, m.BuildInfo),
)
m.reg.WithLogger(m.logger)
m.reg.MustRegister(m.boltClient)
@ -514,7 +515,7 @@ func (m *Launcher) run(ctx context.Context) (err error) {
// ReportUsageStats starts periodic server reporting.
func (m *Launcher) ReportUsageStats(ctx context.Context, interval time.Duration) {
pusher := promusage.NewUsagePusher(m.reg)
pusher := telemetry.NewUsagePusher(m.reg)
logger := m.logger.With(
zap.String("service", "reporting"),
influxlogger.DurationLiteral("interval", interval),

View File

@ -1,4 +1,4 @@
package prometheus
package telemetry
import (
"bytes"

View File

@ -1,4 +1,4 @@
package prometheus
package telemetry
import (
"bytes"

View File

@ -1,34 +1,35 @@
package prometheus
package telemetry
import (
"context"
platform "github.com/influxdata/influxdb"
pr "github.com/influxdata/influxdb/prometheus"
"github.com/prometheus/client_golang/prometheus"
)
var _ platform.UsageService = (*UsageService)(nil)
var defaultMatcher = NewMatcher().
var defaultMatcher = pr.NewMatcher().
Family("influxdb_info").
Family("influxdb_uptime_seconds").
Family("http_api_requests_total",
L("handler", "platform"),
L("method", "GET"),
L("path", "/api/v2"),
L("status", "2XX"),
pr.L("handler", "platform"),
pr.L("method", "GET"),
pr.L("path", "/api/v2"),
pr.L("status", "2XX"),
)
// UsageService filters prometheus metrics for those needed in the usage service.
type UsageService struct {
Filter
pr.Filter
}
// NewUsageService filters the prometheus gatherer to only return metrics
// about the usage statistics.
func NewUsageService(g prometheus.Gatherer) *UsageService {
return &UsageService{
Filter: Filter{
Filter: pr.Filter{
Gatherer: g,
Matcher: defaultMatcher,
},