Document that the process collector only works on Linux

This commit is contained in:
beorn7 2018-02-08 14:01:52 +01:00
parent 9bb6ab929d
commit 154bb450e4
2 changed files with 14 additions and 14 deletions

View File

@ -26,8 +26,11 @@ type processCollector struct {
} }
// NewProcessCollector returns a collector which exports the current state of // NewProcessCollector returns a collector which exports the current state of
// process metrics including cpu, memory and file descriptor usage as well as // process metrics including CPU, memory and file descriptor usage as well as
// the process start time for the given process id under the given namespace. // the process start time for the given process ID under the given namespace.
//
// Currently, the collector depends on a Linux-style proc filesystem and
// therefore only exports metrics for Linux.
func NewProcessCollector(pid int, namespace string) Collector { func NewProcessCollector(pid int, namespace string) Collector {
return NewProcessCollectorPIDFn( return NewProcessCollectorPIDFn(
func() (int, error) { return pid, nil }, func() (int, error) { return pid, nil },
@ -35,11 +38,8 @@ func NewProcessCollector(pid int, namespace string) Collector {
) )
} }
// NewProcessCollectorPIDFn returns a collector which exports the current state // NewProcessCollectorPIDFn works like NewProcessCollector but the process ID is
// of process metrics including cpu, memory and file descriptor usage as well // determined on each collect anew by calling the given pidFn function.
// as the process start time under the given namespace. The given pidFn is
// called on each collect and is used to determine the process to export
// metrics for.
func NewProcessCollectorPIDFn( func NewProcessCollectorPIDFn(
pidFn func() (int, error), pidFn func() (int, error),
namespace string, namespace string,

View File

@ -37,13 +37,13 @@ const (
// DefaultRegisterer and DefaultGatherer are the implementations of the // DefaultRegisterer and DefaultGatherer are the implementations of the
// Registerer and Gatherer interface a number of convenience functions in this // Registerer and Gatherer interface a number of convenience functions in this
// package act on. Initially, both variables point to the same Registry, which // package act on. Initially, both variables point to the same Registry, which
// has a process collector (see NewProcessCollector) and a Go collector (see // has a process collector (currently on Linux only, see NewProcessCollector)
// NewGoCollector) already registered. This approach to keep default instances // and a Go collector (see NewGoCollector) already registered. This approach to
// as global state mirrors the approach of other packages in the Go standard // keep default instances as global state mirrors the approach of other packages
// library. Note that there are caveats. Change the variables with caution and // in the Go standard library. Note that there are caveats. Change the variables
// only if you understand the consequences. Users who want to avoid global state // with caution and only if you understand the consequences. Users who want to
// altogether should not use the convenience function and act on custom // avoid global state altogether should not use the convenience functions and
// instances instead. // act on custom instances instead.
var ( var (
defaultRegistry = NewRegistry() defaultRegistry = NewRegistry()
DefaultRegisterer Registerer = defaultRegistry DefaultRegisterer Registerer = defaultRegistry