func bucketsEqual(actual, expected *bucket.Bucket) bool { if actual.Id.Name != expected.Id.Name { return false } if actual.Id.Source != expected.Id.Source { return false } if actual.Sum() != expected.Sum() { return false } return true }
func (s *RedisStore) Put(b *bucket.Bucket) error { defer utils.MeasureT("bucket.put", time.Now()) rc := s.redisPool.Get() defer rc.Close() b.Lock() key := b.Id.String() value := b.Vals b.Unlock() //TODO(ryandotsmith): Ensure consistent keys are being written. partition := s.bucketPartition("outlet", []byte(key)) rc.Send("MULTI") rc.Send("RPUSH", key, value) rc.Send("EXPIRE", key, 300) rc.Send("SADD", partition, key) rc.Send("EXPIRE", partition, 300) _, err := rc.Do("EXEC") if err != nil { return err } return nil }
func convert(b *bucket.Bucket, lms chan<- *LM) { err := rs.Get(b) if err != nil { fmt.Printf("error=%s\n", err) return } if len(b.Vals) == 0 { fmt.Printf("at=bucket-no-vals bucket=%s\n", b.Id.Name) return } fmt.Printf("at=librato_outlet.process.bucket minute=%d name=%q\n", b.Id.Time.Minute(), b.Id.Name) k := b.Id lms <- &LM{Token: k.Token, Time: ft(k.Time), Source: k.Source, Name: k.Name + ".last", Val: ff(b.Last())} lms <- &LM{Token: k.Token, Time: ft(k.Time), Source: k.Source, Name: k.Name + ".min", Val: ff(b.Min())} lms <- &LM{Token: k.Token, Time: ft(k.Time), Source: k.Source, Name: k.Name + ".max", Val: ff(b.Max())} lms <- &LM{Token: k.Token, Time: ft(k.Time), Source: k.Source, Name: k.Name + ".mean", Val: ff(b.Mean())} lms <- &LM{Token: k.Token, Time: ft(k.Time), Source: k.Source, Name: k.Name + ".median", Val: ff(b.Median())} lms <- &LM{Token: k.Token, Time: ft(k.Time), Source: k.Source, Name: k.Name + ".perc95", Val: ff(b.P95())} lms <- &LM{Token: k.Token, Time: ft(k.Time), Source: k.Source, Name: k.Name + ".perc99", Val: ff(b.P99())} lms <- &LM{Token: k.Token, Time: ft(k.Time), Source: k.Source, Name: k.Name + ".count", Val: fi(b.Count())} lms <- &LM{Token: k.Token, Time: ft(k.Time), Source: k.Source, Name: k.Name + ".sum", Val: ff(b.Sum())} }