Skip to content

Commit

Permalink
Configurable MaxQueueLen
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Payeur Levallois authored and Craig Peterson committed Feb 10, 2016
1 parent 16c0335 commit 1022108
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/scollector/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type Conf struct {
Freq int
// BatchSize is the number of metrics that will be sent in each batch.
BatchSize int
// MaxQueueLen is the number of metrics keept internally.
MaxQueueLen int
// Filter filters collectors matching these terms.
Filter []string
// PProf is an IP:Port binding to be used for debugging with pprof package.
Expand Down
3 changes: 3 additions & 0 deletions cmd/scollector/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ Freq (integer): is the default frequency in seconds for most collectors.
BatchSize (integer): is the number of metrics that will be sent in each batch.
Default is 500.
MaxQueueLen (integer): is the number of metrics keept internally.
Default is 200000.
Filter (array of string): filters collectors matching these terms.
MetricFilters (array of string): filters metrics matching these regular
Expand Down
8 changes: 8 additions & 0 deletions cmd/scollector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ func main() {
if *flagBatchSize > 0 {
collect.BatchSize = *flagBatchSize
}

if conf.MaxQueueLen < collect.BatchSize {
slog.Fatalf("MaxQueueLen must be >= %d (BatchSize)", collect.BatchSize)
}
if conf.MaxQueueLen != 0 {
collect.MaxQueueLen = conf.MaxQueueLen
}

go func() {
const maxMem = 500 * 1024 * 1024 // 500MB
var m runtime.MemStats
Expand Down

0 comments on commit 1022108

Please sign in to comment.