influxdb/gather
Jacob Marble 5f19c6cace
chore: Remove several instances of WithLogger (#15996)
* chore: Remove several instances of WithLogger

* chore: unexport Logger fields

* chore: unexport some more Logger fields

* chore: go fmt

chore: fix test

chore: s/logger/log

chore: fix test

chore: revert http.Handler.Handler constructor initialization

* refactor: integrate review feedback, fix all test nop loggers

* refactor: capitalize all log messages

* refactor: rename two logger to log
2019-12-04 15:10:23 -08:00
..
README.md chore: Remove several instances of WithLogger (#15996) 2019-12-04 15:10:23 -08:00
handler.go chore: Remove several instances of WithLogger (#15996) 2019-12-04 15:10:23 -08:00
metrics.go fix(scraper): remove enriched type label 2019-01-17 10:22:22 -06:00
metrics_test.go fix(scraper): remove enriched type label 2019-01-17 10:22:22 -06:00
prometheus.go add(gather): add writer interface 2019-01-11 13:09:18 -05:00
recorder.go chore: Remove several instances of WithLogger (#15996) 2019-12-04 15:10:23 -08:00
scheduler.go chore: Remove several instances of WithLogger (#15996) 2019-12-04 15:10:23 -08:00
scheduler_test.go chore: Remove several instances of WithLogger (#15996) 2019-12-04 15:10:23 -08:00
scraper.go add(gather): add writer interface 2019-01-11 13:09:18 -05:00
scraper_test.go feat(influxdb): add scraper filter 2019-04-25 11:33:34 -04:00

README.md

How to use this package

Make sure nats is running. Both publisher and subscriber are open

// NATS streaming server
m.natsServer = nats.NewServer(nats.Config{FilestoreDir: m.natsPath})
if err := m.natsServer.Open(); err != nil {
    m.logger.Error("Failed to start nats streaming server", zap.Error(err))
    return err
}

publisher := nats.NewAsyncPublisher("nats-publisher")
if err := publisher.Open(); err != nil {
    m.logger.Error("Failed to connect to streaming server", zap.Error(err))
    return err
}

subscriber := nats.NewQueueSubscriber("nats-subscriber")
if err := subscriber.Open(); err != nil {
    m.logger.Error("Failed to connect to streaming server", zap.Error(err))
    return err
}

Make sure the scraperTargetStorageService is accessible

scraperTargetSvc influxdb.ScraperTargetStoreService = m.boltClient

Setup recorder, Make sure subscriber subscribes use the correct recorder with the correct write service

recorder := gather.PlatformWriter{
    Timeout: time.Millisecond * 30,
    Writer: writer,
}
subscriber.Subscribe(MetricsSubject, "", &RecorderHandler{
    Logger:   logger,
    Recorder: recorder,
})

Start the scheduler

scraperScheduler, err := gather.NewScheduler(10, m.logger, scraperTargetSvc, publisher, subscriber, 0, 0)
if err != nil {
    m.logger.Error("Failed to create scraper subscriber", zap.Error(err))
    return err
}