本文整理匯總了Golang中github.com/influxdata/kapacitor/models.Point類的典型用法代碼示例。如果您正苦於以下問題:Golang Point類的具體用法?Golang Point怎麽用?Golang Point使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Point類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setGroupOnPoint
func setGroupOnPoint(p models.Point, allDimensions bool, dimensions []string) models.Point {
if allDimensions {
dimensions = models.SortedKeys(p.Tags)
}
p.Group = models.TagsToGroupID(dimensions, p.Tags)
p.Dimensions = dimensions
return p
}
示例2: setGroupOnPoint
func setGroupOnPoint(p models.Point, allDimensions bool, dimensions models.Dimensions) models.Point {
if allDimensions {
dimensions.TagNames = models.SortedKeys(p.Tags)
}
p.Group = models.ToGroupID(p.Name, p.Tags, dimensions)
p.Dimensions = dimensions
return p
}
示例3: runStats
func (s *StatsNode) runStats([]byte) error {
ticker := time.NewTicker(s.s.Interval)
defer ticker.Stop()
point := models.Point{
Name: "stats",
Tags: map[string]string{"node": s.en.Name()},
}
for {
select {
case <-s.closing:
return nil
case now := <-ticker.C:
point.Time = now.UTC()
stats := s.en.nodeStatsByGroup()
for group, stat := range stats {
point.Fields = stat.Fields
point.Group = group
point.Dimensions = stat.Dimensions
point.Tags = stat.Tags
for _, out := range s.outs {
err := out.CollectPoint(point)
if err != nil {
return err
}
}
}
}
}
}
示例4: emit
// Emit a set of stats data points.
func (s *StatsNode) emit(now time.Time) error {
s.timer.Start()
point := models.Point{
Name: "stats",
Tags: map[string]string{"node": s.en.Name()},
Time: now.UTC(),
}
if s.s.AlignFlag {
point.Time = point.Time.Round(s.s.Interval)
}
stats := s.en.nodeStatsByGroup()
for group, stat := range stats {
point.Fields = stat.Fields
point.Group = group
point.Dimensions = stat.Dimensions
point.Tags = stat.Tags
s.timer.Pause()
for _, out := range s.outs {
err := out.CollectPoint(point)
if err != nil {
return err
}
}
s.timer.Resume()
}
s.timer.Stop()
return nil
}
示例5: reduceResultToPoint
// take the result of a reduce operation and convert it to a point
func reduceResultToPoint(field string, v interface{}, tmax time.Time, usePointTimes bool) models.Point {
if pp, ok := v.(tsdb.PositionPoint); ok {
p := models.Point{}
if usePointTimes {
p.Time = time.Unix(pp.Time, 0).UTC()
} else {
p.Time = tmax
}
p.Fields = models.Fields{field: pp.Value}
p.Tags = pp.Tags
return p
}
p := models.Point{}
p.Fields = models.Fields{field: v}
p.Time = tmax
return p
}
示例6: runStats
func (s *StatsNode) runStats([]byte) error {
ticker := time.NewTicker(s.s.Interval)
defer ticker.Stop()
point := models.Point{
Name: "stats",
Tags: map[string]string{"node": s.en.Name()},
}
for {
select {
case <-s.closing:
return nil
case now := <-ticker.C:
point.Time = now
count := s.en.collectedCount()
point.Fields = models.Fields{"collected": count}
for _, out := range s.outs {
err := out.CollectPoint(point)
if err != nil {
return err
}
}
}
}
}
示例7: WritePointForRecording
func WritePointForRecording(w io.Writer, p models.Point, precision string) error {
fmt.Fprintf(w, "%s\n%s\n", p.Database, p.RetentionPolicy)
w.Write(p.Bytes(precision))
w.Write([]byte("\n"))
return nil
}
示例8: combineBuffer
// Combine a set of points into all their combinations.
func (n *CombineNode) combineBuffer(buf *buffer) error {
if len(buf.Points) == 0 {
return nil
}
l := len(n.expressions)
expressions, ok := n.expressionsByGroup[buf.Group]
if !ok {
expressions = make([]stateful.Expression, l)
for i, expr := range n.expressions {
expressions[i] = expr.CopyReset()
}
n.expressionsByGroup[buf.Group] = expressions
}
// Compute matching result for all points
matches := make([]map[int]bool, l)
for i := 0; i < l; i++ {
matches[i] = make(map[int]bool, len(buf.Points))
}
for idx, p := range buf.Points {
for i := range expressions {
matched, err := EvalPredicate(expressions[i], n.scopePools[i], p.Time, p.Fields, p.Tags)
if err != nil {
n.logger.Println("E! evaluating lambda expression:", err)
}
matches[i][idx] = matched
}
}
p := models.Point{
Name: buf.Name,
Group: buf.Group,
Dimensions: buf.Dimensions,
}
dimensions := p.Dimensions.ToSet()
set := make([]rawPoint, l)
return n.combination.Do(len(buf.Points), l, func(indices []int) error {
valid := true
for s := 0; s < l; s++ {
found := false
for i := range indices {
if matches[s][indices[i]] {
set[s] = buf.Points[indices[i]]
indices = append(indices[0:i], indices[i+1:]...)
found = true
break
}
}
if !found {
valid = false
break
}
}
if valid {
rp := n.merge(set, dimensions)
p.Time = rp.Time.Round(n.c.Tolerance)
p.Fields = rp.Fields
p.Tags = rp.Tags
n.timer.Pause()
for _, out := range n.outs {
err := out.CollectPoint(p)
if err != nil {
return err
}
}
n.timer.Resume()
}
return nil
})
}