Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
baris committed Jul 31, 2015
1 parent 5aa2180 commit 37544aa
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions fullerite.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"Diamond"
],
"handlers": {
"Graphite": {},
"SignalFx": {
"authToken": "token",
"endpoint": "http://somethingsomething.com/blah",
"interval": "10.0"
},
"Graphite": {}
}
},
"prefix": "test.",
"interval": 10,
Expand Down
2 changes: 1 addition & 1 deletion src/fullerite/collectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func readCollectorConfig(collector collector.Collector) {
}

func runCollector(collector collector.Collector) {
log.Info("Running ", collector)
for {
log.Info("Collecting from ", collector)
collector.Collect()
time.Sleep(time.Duration(collector.Interval()) * time.Second)
}
Expand Down
8 changes: 6 additions & 2 deletions src/fullerite/handler/graphite.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ type Graphite struct {
// NewGraphite returns a new Graphite handler.
func NewGraphite() *Graphite {
g := new(Graphite)
g.name = "SignalFx"
g.name = "Graphite"
g.maxBufferSize = DefaultBufferSize
g.channel = make(chan metric.Metric)

return g
}

// Configure accepts the different configuration options
func (g Graphite) Configure(conf *map[string]string) {
// TODO: implement
}

// Run sends metrics in the channel to the graphite server.
func (g Graphite) Run() {
// TODO: check interval and queue size and metrics.
Expand Down
8 changes: 2 additions & 6 deletions src/fullerite/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Handler interface {

// taken care of by the base
Name() string
String() string
Channel() chan metric.Metric

Interval() int
Expand Down Expand Up @@ -115,12 +116,7 @@ func (handler *BaseHandler) SetInterval(val int) {
handler.interval = val
}

// Configure : this takes a dictionary of values with which the handler can configure itself
func (handler *BaseHandler) Configure(*map[string]string) {
// noop
}

// String returns the handler name in a printable format.
func (handler *BaseHandler) String() string {
return handler.Name() + "Handler"
return handler.name + "Handler"
}
9 changes: 5 additions & 4 deletions src/fullerite/handler/signalfx.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package handler

import (
"bytes"
"fullerite/metric"
"github.com/golang/protobuf/proto"

"bytes"
"io/ioutil"
"net/http"
"time"

"github.com/golang/protobuf/proto"
)

// SignalFx Handler
Expand All @@ -25,7 +27,7 @@ func NewSignalFx() *SignalFx {
return s
}

// Configure : accepts the different configuration options for the signalfx handler
// Configure accepts the different configuration options for the signalfx handler
func (s *SignalFx) Configure(config *map[string]string) {
asmap := *config
var exists bool
Expand All @@ -41,7 +43,6 @@ func (s *SignalFx) Configure(config *map[string]string) {

// Run send metrics in the channel to SignalFx.
func (s *SignalFx) Run() {
log.Info("Starting signalfx handler...")
datapoints := make([]*DataPoint, 0, s.maxBufferSize)

lastEmission := time.Now()
Expand Down
9 changes: 2 additions & 7 deletions src/fullerite/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import (

func startHandlers(c Config) (handlers []handler.Handler) {
log.Info("Starting handlers...")

for name, config := range c.Handlers {
handler := buildHandler(name)
handler := handler.New(name)

// apply any global configs
handler.SetInterval(c.Interval)
Expand All @@ -21,16 +20,12 @@ func startHandlers(c Config) (handlers []handler.Handler) {

handlers = append(handlers, handler)

log.Info("Running ", handler)
go handler.Run()
}
return handlers
}

func buildHandler(name string) handler.Handler {
handler := handler.New(name)
return handler
}

func writeToHandlers(handlers []handler.Handler, metric metric.Metric) {
for _, handler := range handlers {
handler.Channel() <- metric
Expand Down

0 comments on commit 37544aa

Please sign in to comment.