Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 2.0.3
  • Loading branch information
andyone authored Jun 29, 2016
2 parents 87cb6be + 6341117 commit 8a5fbc3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
12 changes: 4 additions & 8 deletions examples/basic_example.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,19 @@ func main() {
librato.Mail = "[email protected]"
librato.Token = "abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234"

// We use prefix "example:" which will be added to each gauge and counter sended
// to Librato
librato.Prefix = "example:"

for {
errs := librato.AddMetric(
librato.Gauge{
Name: "gauge_1",
Name: "example:gauge_1",
Value: rand.Int(1000),
},
librato.Gauge{
Name: "gauge_2",
Value: float64(rand.Int(1000)) / float64(rand.Int(20)),
Name: "example:gauge_2",
Value: float64(rand.Int(1000)) / 5.0,
Source: "go_librato_example",
},
librato.Counter{
Name: "counter_1",
Name: "example:counter_1",
Value: rand.Int(1000),
},
)
Expand Down
21 changes: 1 addition & 20 deletions librato.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
// ////////////////////////////////////////////////////////////////////////////////// //

// VERSION contains current version of librato package and used as part of User-Agent
const VERSION = "2.0.2"
const VERSION = "2.0.3"

// ////////////////////////////////////////////////////////////////////////////////// //

Expand Down Expand Up @@ -311,8 +311,6 @@ func AddMetric(m ...Measurement) []error {
}
}

appendGlobalPrefix(data)

return execRequest(req.POST, APIEndpoint+"/v1/metrics/", data)
}

Expand Down Expand Up @@ -393,8 +391,6 @@ func (mt *Metrics) Send() []error {

mt.queue = make([]Measurement, 0)

appendGlobalPrefix(data)

errs := execRequest(req.POST, APIEndpoint+"/v1/metrics/", data)

mt.execErrorHandler(errs)
Expand Down Expand Up @@ -535,21 +531,6 @@ func convertMeasurementSlice(queue []Measurement) measurements {
return result
}

// appendGlobalPrefix append global prefix to each measurement
func appendGlobalPrefix(data measurements) {
if Prefix == "" {
return
}

for _, c := range data.Counters {
c.Name = Prefix + c.Name
}

for _, g := range data.Gauges {
g.Name = Prefix + g.Name
}
}

// execRequest create and execute request to API
func execRequest(method, url string, data interface{}) []error {
request := req.Request{
Expand Down

0 comments on commit 8a5fbc3

Please sign in to comment.