Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update batch group stats to be by len(b.Points) #605

Merged
merged 2 commits into from
Jun 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ batch
- [#586](https://github.com/influxdata/kapacitor/pull/586): Add spread stateful function. thanks @upccup!
- [#600](https://github.com/influxdata/kapacitor/pull/600): Add close http response after handler laert post, thanks @jsvisa!
- [#606](https://github.com/influxdata/kapacitor/pull/606): Add Holt-Winters forecasting method.
- [#605](https://github.com/influxdata/kapacitor/pull/605): BREAKING: StatsNode for batch edge now count the number of points in a batch instead of count batches as a whole.
This is only breaking if you have a deadman switch configured on a batch edge.

### Bugfixes

Expand Down
20 changes: 10 additions & 10 deletions edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (e *Edge) NextPoint() (p models.Point, ok bool) {
case p, ok = <-e.stream:
if ok {
e.emitted.Add(1)
e.incEmitted(p.Group, p.Tags, p.Dimensions)
e.incEmitted(p.Group, p.Tags, p.Dimensions, 1)
}
}
return
Expand All @@ -159,15 +159,15 @@ func (e *Edge) NextBatch() (b models.Batch, ok bool) {
case b, ok = <-e.batch:
if ok {
e.emitted.Add(1)
e.incEmitted(b.Group, b.Tags, b.PointDimensions())
e.incEmitted(b.Group, b.Tags, b.PointDimensions(), int64(len(b.Points)))
}
}
return
}

func (e *Edge) CollectPoint(p models.Point) error {
e.collected.Add(1)
e.incCollected(p.Group, p.Tags, p.Dimensions)
e.incCollected(p.Group, p.Tags, p.Dimensions, 1)
select {
case <-e.aborted:
return ErrAborted
Expand All @@ -178,7 +178,7 @@ func (e *Edge) CollectPoint(p models.Point) error {

func (e *Edge) CollectBatch(b models.Batch) error {
e.collected.Add(1)
e.incCollected(b.Group, b.Tags, b.PointDimensions())
e.incCollected(b.Group, b.Tags, b.PointDimensions(), int64(len(b.Points)))
select {
case <-e.aborted:
return ErrAborted
Expand All @@ -188,17 +188,17 @@ func (e *Edge) CollectBatch(b models.Batch) error {
}

// Increment the emitted count of the group for this edge.
func (e *Edge) incEmitted(group models.GroupID, tags models.Tags, dims []string) {
func (e *Edge) incEmitted(group models.GroupID, tags models.Tags, dims []string, count int64) {
// we are "manually" calling Unlock() and not using defer, because this method is called
// in hot locations (NextPoint/CollectPoint) and defer have some performance penalty
e.groupMu.Lock()

if stats, ok := e.groupStats[group]; ok {
stats.emitted++
stats.emitted += count
e.groupMu.Unlock()
} else {
stats = &edgeStat{
emitted: 1,
emitted: count,
tags: tags,
dims: dims,
}
Expand All @@ -208,17 +208,17 @@ func (e *Edge) incEmitted(group models.GroupID, tags models.Tags, dims []string)
}

// Increment the collected count of the group for this edge.
func (e *Edge) incCollected(group models.GroupID, tags models.Tags, dims []string) {
func (e *Edge) incCollected(group models.GroupID, tags models.Tags, dims []string, count int64) {
// we are "manually" calling Unlock() and not using defer, because this method is called
// in hot locations (NextPoint/CollectPoint) and defer have some performance penalty
e.groupMu.Lock()

if stats, ok := e.groupStats[group]; ok {
stats.collected++
stats.collected += count
e.groupMu.Unlock()
} else {
stats = &edgeStat{
collected: 1,
collected: count,
tags: tags,
dims: dims,
}
Expand Down