Skip to content

Commit

Permalink
Merge pull request #7 from signalfx/output-bugfix
Browse files Browse the repository at this point in the history
fix batching in SignalFx output plugin
  • Loading branch information
charless-splunk authored Jan 16, 2018
2 parents e875f44 + 68db3e1 commit 625d9e5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v1.5.1.sfx1 [2018-01-16]

### Release Notes

- Minor bug fix to correctly batch metrics in SignalFx output plugin
- Minor enhancement to ensure SignalFx metadata plugin has at least 1 go routine to gather process list information

## v1.5.1.sfx0 [2018-01-12]

### Release Notes
Expand Down
7 changes: 5 additions & 2 deletions plugins/inputs/signalfx_metadata/process-info.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ func NewProcessInfo(bufferSize int, numWorkers int) *ProcessInfo {
bufferSize: bufferSize,
numWorkers: numWorkers,
}

for i := 0; i < numWorkers; i++ {
// ensure that the number of workers is always 1
if s.numWorkers < 1 {
s.numWorkers = 1
}
for i := 0; i < s.numWorkers; i++ {
newWorkerProcess(s.processIn)
}

Expand Down
1 change: 1 addition & 0 deletions plugins/inputs/signalfx_metadata/signalfx-metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const pluginVersion = "0.0.30"
var sampleConfig = `
## SignalFx metadata plugin reports metadata properties for the host
## Process List Collection Settings
## number of go routines used to collect the process list (must be 1 or greater)
# NumberOfGoRoutines = 3
## The buffer size should be greater than or equal to the length of all
## processes on the host
Expand Down
10 changes: 4 additions & 6 deletions plugins/outputs/signalfx/signalfx.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func (s *SignalFx) Write(metrics []telegraf.Metric) error {
// Add metric as a datapoint
datapoints = append(datapoints, dp)

if len(datapoints) == s.BatchSize {
if len(datapoints) >= s.BatchSize {
s.emitDatapoints(datapoints)
datapoints = datapoints[:0]
}
Expand All @@ -355,17 +355,15 @@ func (s *SignalFx) Write(metrics []telegraf.Metric) error {
// Add event
events = append(events, ev)

if len(events) == s.BatchSize {
if len(events) >= s.BatchSize {
s.emitEvents(events)
events = events[:0]
}
}
}
s.emitDatapoints(datapoints)
datapoints = datapoints[:0]
s.emitEvents(events)
events = events[:0]
}
s.emitDatapoints(datapoints)
s.emitEvents(events)
return nil
}

Expand Down

0 comments on commit 625d9e5

Please sign in to comment.