Comment more packages to pass go lint

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-10-02 11:50:18 -04:00
parent 33e974ce99
commit 451421b615
54 changed files with 255 additions and 121 deletions

View File

@@ -14,22 +14,24 @@ import (
)
var (
// ErrAlreadyCollected is returned when a cgroups is already being monitored
ErrAlreadyCollected = errors.New("cgroup is already being collected")
ErrCgroupNotExists = errors.New("cgroup does not exist in the collector")
// ErrCgroupNotExists is returns when a cgroup no longer exists
ErrCgroupNotExists = errors.New("cgroup does not exist in the collector")
)
// Trigger will be called when an event happens and provides the cgroup
// where the event originated from
type Trigger func(string, string, cgroups.Cgroup)
// New registers the Collector with the provided namespace and returns it so
// newCollector registers the collector with the provided namespace and returns it so
// that cgroups can be added for collection
func NewCollector(ns *metrics.Namespace) *Collector {
func newCollector(ns *metrics.Namespace) *collector {
if ns == nil {
return &Collector{}
return &collector{}
}
// add machine cpus and memory info
c := &Collector{
c := &collector{
ns: ns,
cgroups: make(map[string]*task),
}
@@ -52,9 +54,9 @@ func taskID(id, namespace string) string {
return fmt.Sprintf("%s-%s", id, namespace)
}
// Collector provides the ability to collect container stats and export
// collector provides the ability to collect container stats and export
// them in the prometheus format
type Collector struct {
type collector struct {
mu sync.RWMutex
cgroups map[string]*task
@@ -62,13 +64,13 @@ type Collector struct {
metrics []*metric
}
func (c *Collector) Describe(ch chan<- *prometheus.Desc) {
func (c *collector) Describe(ch chan<- *prometheus.Desc) {
for _, m := range c.metrics {
ch <- m.desc(c.ns)
}
}
func (c *Collector) Collect(ch chan<- prometheus.Metric) {
func (c *collector) Collect(ch chan<- prometheus.Metric) {
c.mu.RLock()
wg := &sync.WaitGroup{}
for _, t := range c.cgroups {
@@ -79,7 +81,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) {
wg.Wait()
}
func (c *Collector) collect(id, namespace string, cg cgroups.Cgroup, ch chan<- prometheus.Metric, wg *sync.WaitGroup) {
func (c *collector) collect(id, namespace string, cg cgroups.Cgroup, ch chan<- prometheus.Metric, wg *sync.WaitGroup) {
defer wg.Done()
stats, err := cg.Stat(cgroups.IgnoreNotExist)
if err != nil {
@@ -92,7 +94,7 @@ func (c *Collector) collect(id, namespace string, cg cgroups.Cgroup, ch chan<- p
}
// Add adds the provided cgroup and id so that metrics are collected and exported
func (c *Collector) Add(id, namespace string, cg cgroups.Cgroup) error {
func (c *collector) Add(id, namespace string, cg cgroups.Cgroup) error {
if c.ns == nil {
return nil
}
@@ -110,7 +112,7 @@ func (c *Collector) Add(id, namespace string, cg cgroups.Cgroup) error {
}
// Remove removes the provided cgroup by id from the collector
func (c *Collector) Remove(id, namespace string) {
func (c *collector) Remove(id, namespace string) {
if c.ns == nil {
return
}