Skip to content

Commit

Permalink
Fix up PR
Browse files Browse the repository at this point in the history
  • Loading branch information
tevjef committed Mar 26, 2017
1 parent 0608de7 commit dbbff91
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions runstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (r *runStats) onNewPoint(fields collector.Fields) {
pt, err := client.NewPoint(r.config.Measurement, fields.Tags(), fields.Values(), time.Now())

if err != nil {
r.logger.Fatalln(errors.Wrap(err, "Couldn't create InfluxDB point"))
r.logger.Fatalln(errors.Wrap(err, "error while creating point"))
}

r.pc <- pt
Expand All @@ -191,7 +191,7 @@ func (r *runStats) newBatch() (bp client.BatchPoints, err error) {
})

if err != nil {
r.logger.Fatalln(errors.Wrap(err, "Couldn't create BatchPoints"))
r.logger.Fatalln(errors.Wrap(err, "could not create BatchPoints"))
}

return
Expand All @@ -209,27 +209,25 @@ func (r *runStats) loop(interval time.Duration) {
}

if err := r.client.Write(r.points); err != nil {
r.logger.Fatalln(errors.Wrap(err, "Couldn't write points to InfluxDB"))
r.logger.Fatalln(errors.Wrap(err, "could not write points to InfluxDB"))
continue
}

r.points = nil

bp, err := client.NewBatchPoints(client.BatchPointsConfig{
Database: r.config.Database,
Precision: r.config.Precision,
RetentionPolicy: r.config.RetentionPolicy,
})
bp, err := r.newBatch()

if err != nil {
r.logger.Fatalln(errors.Wrap(err, "Couldn't create BatchPoints"))
r.logger.Fatalln(errors.Wrap(err, "could not create BatchPoints"))
continue
}

r.points = bp

case pt := <-r.pc:
if r.points != nil {
r.logger.Println(pt.String())

r.points.AddPoint(pt)
}
}
Expand Down

0 comments on commit dbbff91

Please sign in to comment.