From 3d690d62a63482ca79cb203ccdcd0d2a4654f83c Mon Sep 17 00:00:00 2001 From: Tudor Golubenco Date: Tue, 2 May 2017 16:13:24 +0200 Subject: [PATCH] Follow up addressing comments in #4127 Follow up for #4127 to address comments. --- metricbeat/docs/modules/system.asciidoc | 2 +- metricbeat/metricbeat.full.yml | 2 +- metricbeat/module/system/_meta/config.full.yml | 2 +- metricbeat/module/system/_meta/docs.asciidoc | 2 +- metricbeat/module/system/process/helper.go | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/metricbeat/docs/modules/system.asciidoc b/metricbeat/docs/modules/system.asciidoc index 4393c77dae8..1127b69dc31 100644 --- a/metricbeat/docs/modules/system.asciidoc +++ b/metricbeat/docs/modules/system.asciidoc @@ -30,7 +30,7 @@ metricbeat.modules: *`process.include_top_n`*:: These options allow you to filter out all processes that are not in the top N by CPU or memory, in order to reduce the number of documents created. If both the `by_cpu` and `by_memory` options are used, the -reunion of the two tops is included. +union of the two sets is included. *`process.include_top_n.enabled`*:: Set to false to disable the top N feature and include all processes, regardless of the other options. The default is `true`, diff --git a/metricbeat/metricbeat.full.yml b/metricbeat/metricbeat.full.yml index 43debb001c7..04212daacac 100644 --- a/metricbeat/metricbeat.full.yml +++ b/metricbeat/metricbeat.full.yml @@ -66,7 +66,7 @@ metricbeat.modules: # These options allow you to filter out all processes that are not # in the top N by CPU or memory, in order to reduce the number of documents created. - # If both the `by_cpu` and `by_memory` options are used, the reunion of the two tops + # If both the `by_cpu` and `by_memory` options are used, the union of the two sets # is included. #process.include_top_n: # diff --git a/metricbeat/module/system/_meta/config.full.yml b/metricbeat/module/system/_meta/config.full.yml index 53d69fc970c..4bc7f59f6a6 100644 --- a/metricbeat/module/system/_meta/config.full.yml +++ b/metricbeat/module/system/_meta/config.full.yml @@ -38,7 +38,7 @@ # These options allow you to filter out all processes that are not # in the top N by CPU or memory, in order to reduce the number of documents created. - # If both the `by_cpu` and `by_memory` options are used, the reunion of the two tops + # If both the `by_cpu` and `by_memory` options are used, the union of the two sets # is included. #process.include_top_n: # diff --git a/metricbeat/module/system/_meta/docs.asciidoc b/metricbeat/module/system/_meta/docs.asciidoc index 87e37f1e9c7..e385a7b520b 100644 --- a/metricbeat/module/system/_meta/docs.asciidoc +++ b/metricbeat/module/system/_meta/docs.asciidoc @@ -25,7 +25,7 @@ metricbeat.modules: *`process.include_top_n`*:: These options allow you to filter out all processes that are not in the top N by CPU or memory, in order to reduce the number of documents created. If both the `by_cpu` and `by_memory` options are used, the -reunion of the two tops is included. +union of the two sets is included. *`process.include_top_n.enabled`*:: Set to false to disable the top N feature and include all processes, regardless of the other options. The default is `true`, diff --git a/metricbeat/module/system/process/helper.go b/metricbeat/module/system/process/helper.go index b3bf242bfdd..b9d84faa90c 100644 --- a/metricbeat/module/system/process/helper.go +++ b/metricbeat/module/system/process/helper.go @@ -339,7 +339,7 @@ func (procStats *ProcStats) GetProcStats() ([]common.MapStr, error) { return nil, err } - processes := []Process{} + var processes []Process newProcs := make(ProcsMap, len(pids)) for _, pid := range pids { @@ -376,7 +376,7 @@ func (procStats *ProcStats) GetProcStats() ([]common.MapStr, error) { processes = procStats.includeTopProcesses(processes) logp.Debug("processes", "Filtered top processes down to %d processes", len(processes)) - procs := []common.MapStr{} + procs := make([]common.MapStr, 0, len(processes)) for _, process := range processes { proc := procStats.getProcessEvent(&process) procs = append(procs, proc) @@ -393,7 +393,7 @@ func (procStats *ProcStats) includeTopProcesses(processes []Process) []Process { return processes } - result := []Process{} + var result []Process if procStats.IncludeTop.ByCPU > 0 { sort.Slice(processes, func(i, j int) bool { return processes[i].cpuTotalPct > processes[j].cpuTotalPct