Skip to content

Commit

Permalink
use librato's complex measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
♠ ace hacker committed May 7, 2013
1 parent 14e908e commit a7762ff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bucket/log_tuple.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package bucket
import (
"bytes"
"errors"
"strconv"
"github.com/kr/logfmt"
"strconv"
)

type logTuple struct {
Expand Down
32 changes: 15 additions & 17 deletions outlet/librato_outlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ type Payload struct {
Name string `json:"name"`
Time int64 `json:"measure_time"`
Val string `json:"value,omitempty"`
Min string `json:"min,omitempty"`
Max string `json:"max,omitempty"`
Count string `json:"count,omitempty"`
Sum string `json:"sum,omitempty"`
Count int `json:"count,omitempty"`
Sum float64 `json:"sum,omitempty"`
Min float64 `json:"min,omitempty"`
Max float64 `json:"max,omitempty"`
Source string `json:"source,omitempty"`
User string `json:",omitempty"`
Pass string `json:",omitempty"`
Expand Down Expand Up @@ -116,32 +116,30 @@ func (l *LibratoOutlet) convert() {
fmt.Printf("at=bucket-no-vals bucket=%s\n", bucket.Id.Name)
continue
}
//TODO(ryandotsmith): This is getting out of control.
//We need a succinct way to building payloads.
countAttr := &LibratoAttributes{Min: 0, Units: "count"}
attrs := &LibratoAttributes{Min: 0, Units: bucket.Id.Units}
//Submit a complex measurement.
//This is ane experimental
//use of librato's complex measurement API. We could potentially
//not submit all of the metrics individually and instad use this build
//api endpoint.
l.Conversions <- &Payload{
Attr: attrs,
User: bucket.Id.User,
Pass: bucket.Id.Pass,
Time: ft(bucket.Id.Time),
Source: bucket.Id.Source,
Name: bucket.Id.Name,
Min: ff(bucket.Min()),
Max: ff(bucket.Max()),
Sum: ff(bucket.Sum()),
Count: strconv.Itoa(bucket.Count()),
Min: bucket.Min(),
Max: bucket.Max(),
Sum: bucket.Sum(),
Count: bucket.Count(),
}
//TODO(ryandotsmith): Some day Librato will support these
//metrics in their complex measurement api. We will need to
//move these up ^^ into the complex payload.
l.Conversions <- &Payload{Attr: attrs, User: bucket.Id.User, Pass: bucket.Id.Pass, Time: ft(bucket.Id.Time), Source: bucket.Id.Source, Name: bucket.Id.Name + ".last", Val: ff(bucket.Last())}
l.Conversions <- &Payload{Attr: attrs, User: bucket.Id.User, Pass: bucket.Id.Pass, Time: ft(bucket.Id.Time), Source: bucket.Id.Source, Name: bucket.Id.Name + ".min", Val: ff(bucket.Min())}
l.Conversions <- &Payload{Attr: attrs, User: bucket.Id.User, Pass: bucket.Id.Pass, Time: ft(bucket.Id.Time), Source: bucket.Id.Source, Name: bucket.Id.Name + ".max", Val: ff(bucket.Max())}
l.Conversions <- &Payload{Attr: attrs, User: bucket.Id.User, Pass: bucket.Id.Pass, Time: ft(bucket.Id.Time), Source: bucket.Id.Source, Name: bucket.Id.Name + ".mean", Val: ff(bucket.Mean())}
l.Conversions <- &Payload{Attr: attrs, User: bucket.Id.User, Pass: bucket.Id.Pass, Time: ft(bucket.Id.Time), Source: bucket.Id.Source, Name: bucket.Id.Name + ".median", Val: ff(bucket.Median())}
l.Conversions <- &Payload{Attr: attrs, User: bucket.Id.User, Pass: bucket.Id.Pass, Time: ft(bucket.Id.Time), Source: bucket.Id.Source, Name: bucket.Id.Name + ".perc95", Val: ff(bucket.P95())}
l.Conversions <- &Payload{Attr: attrs, User: bucket.Id.User, Pass: bucket.Id.Pass, Time: ft(bucket.Id.Time), Source: bucket.Id.Source, Name: bucket.Id.Name + ".perc99", Val: ff(bucket.P99())}
l.Conversions <- &Payload{Attr: attrs, User: bucket.Id.User, Pass: bucket.Id.Pass, Time: ft(bucket.Id.Time), Source: bucket.Id.Source, Name: bucket.Id.Name + ".sum", Val: ff(bucket.Sum())}
l.Conversions <- &Payload{Attr: countAttr, User: bucket.Id.User, Pass: bucket.Id.Pass, Time: ft(bucket.Id.Time), Source: bucket.Id.Source, Name: bucket.Id.Name + ".count", Val: fi(bucket.Count())}
fmt.Printf("measure.bucket.conversion.delay=%d\n", bucket.Id.Delay(time.Now()))
}
}
Expand Down

0 comments on commit a7762ff

Please sign in to comment.