Skip to content

Commit

Permalink
Merged pull request influxdata#1350 from influxdata/go-scraper-rename
Browse files Browse the repository at this point in the history
Update files and static to files-discovery and static-discovery
  • Loading branch information
nathanielc committed May 1, 2017
2 parents 3f5c354 + c6d5d2c commit 14ae0f1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 18 deletions.
4 changes: 2 additions & 2 deletions server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ type Config struct {
Consul []consul.Config `toml:"consul" override:"consul,element-key=id"`
DNS []dns.Config `toml:"dns" override:"dns,element-key=id"`
EC2 []ec2.Config `toml:"ec2" override:"ec2,element-key=id"`
Files []file.Config `toml:"files" override:"files,element-key=id"`
Files []file.Config `toml:"files-discovery" override:"files-discovery,element-key=id"`
GCE []gce.Config `toml:"gce" override:"gce,element-key=id"`
Marathon []marathon.Config `toml:"marathon" override:"marathon,element-key=id"`
Nerve []nerve.Config `toml:"nerve" override:"nerve,element-key=id"`
Serverset []serverset.Config `toml:"serverset" override:"serverset,element-key=id"`
Static []static.Config `toml:"static" override:"static,element-key=id"`
Static []static.Config `toml:"static-discovery" override:"static-discovery,element-key=id"`
Triton []triton.Config `toml:"triton" override:"triton,element-key=id"`

// Third-party integrations
Expand Down
12 changes: 6 additions & 6 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,11 +737,11 @@ func (s *Server) appendEC2Service(r scraper.Registry) {

func (s *Server) appendFileService(r scraper.Registry) {
c := s.config.Files
l := s.LogService.NewLogger("[files] ", log.LstdFlags)
l := s.LogService.NewLogger("[files-discovery] ", log.LstdFlags)
srv := file.NewService(c, r, l)
s.FileService = srv
s.SetDynamicService("files", srv)
s.AppendService("files", srv)
s.SetDynamicService("files-discovery", srv)
s.AppendService("files-discovery", srv)
}

func (s *Server) appendGCEService(r scraper.Registry) {
Expand Down Expand Up @@ -782,11 +782,11 @@ func (s *Server) appendServersetService(r scraper.Registry) {

func (s *Server) appendStaticService(r scraper.Registry) {
c := s.config.Static
l := s.LogService.NewLogger("[static] ", log.LstdFlags)
l := s.LogService.NewLogger("[static-discovery] ", log.LstdFlags)
srv := static.NewService(c, r, l)
s.StaticService = srv
s.SetDynamicService("static", srv)
s.AppendService("static", srv)
s.SetDynamicService("static-discovery", srv)
s.AppendService("static-discovery", srv)
}

func (s *Server) appendTritonService(r scraper.Registry) {
Expand Down
12 changes: 6 additions & 6 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7179,8 +7179,8 @@ func TestServer_ListServiceTests(t *testing.T) {
},
},
{
Link: client.Link{Relation: "self", Href: "/kapacitor/v1/service-tests/files"},
Name: "files",
Link: client.Link{Relation: "self", Href: "/kapacitor/v1/service-tests/files-discovery"},
Name: "files-discovery",
Options: client.ServiceTestOptions{
"id": "",
},
Expand Down Expand Up @@ -7331,8 +7331,8 @@ func TestServer_ListServiceTests(t *testing.T) {
},
},
{
Link: client.Link{Relation: "self", Href: "/kapacitor/v1/service-tests/static"},
Name: "static",
Link: client.Link{Relation: "self", Href: "/kapacitor/v1/service-tests/static-discovery"},
Name: "static-discovery",
Options: client.ServiceTestOptions{
"id": "",
},
Expand Down Expand Up @@ -7461,8 +7461,8 @@ func TestServer_ListServiceTests_WithPattern(t *testing.T) {
},
},
{
Link: client.Link{Relation: "self", Href: "/kapacitor/v1/service-tests/static"},
Name: "static",
Link: client.Link{Relation: "self", Href: "/kapacitor/v1/service-tests/static-discovery"},
Name: "static-discovery",
Options: client.ServiceTestOptions{
"id": "",
},
Expand Down
2 changes: 1 addition & 1 deletion services/file/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (f Config) PromConfig() *config.FileSDConfig {

// Service return discoverer type
func (f Config) Service() string {
return "files"
return "files-discovery"
}

// ServiceID returns the discoverers name
Expand Down
10 changes: 9 additions & 1 deletion services/scraper/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scraper
import (
"fmt"
"log"
"math"
"sync"

"github.com/influxdata/influxdb/models"
Expand Down Expand Up @@ -118,6 +119,13 @@ func (s *Service) scrape() {

// Append tranforms prometheus samples and inserts data into the tasks pipeline
func (s *Service) Append(sample *model.Sample) error {
value := float64(sample.Value)
// Remove all NaN values
// TODO: Add counter stat for this variable
if math.IsNaN(value) {
return nil
}

var err error
db := ""
rp := ""
Expand Down Expand Up @@ -154,7 +162,7 @@ func (s *Service) Append(sample *model.Sample) error {
}

fields := models.Fields{
"value": float64(sample.Value),
"value": value,
}

pt, err := models.NewPoint(job, models.NewTags(tags), fields, sample.Timestamp.Time())
Expand Down
4 changes: 2 additions & 2 deletions services/static/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (s *Config) Init() {
// Validate validates Static configuration values
func (s Config) Validate() error {
if s.ID == "" {
return fmt.Errorf("azure discovery must be given a ID")
return fmt.Errorf("static discovery must be given a ID")
}
return nil
}
Expand Down Expand Up @@ -64,7 +64,7 @@ func (s Config) PromConfig() []*config.TargetGroup {

// Service return discoverer type
func (s Config) Service() string {
return "static"
return "static-discovery"
}

// ServiceID returns the discoverers name
Expand Down

0 comments on commit 14ae0f1

Please sign in to comment.