Documentation

Overview

    Package metrics defines a concurrently-accessible metrics collector.

    A *metrics.M value exports methods to track integer counters and maximum values. A metric has a caller-assigned string name that is not interpreted by the collector except to locate its stored value.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type M

    type M struct {
    	// contains filtered or unexported fields
    }

      An M collects counters and maximum value trackers. A nil *M is valid, and discards all metrics. The methods of an *M are safe for concurrent use by multiple goroutines.

      func New

      func New() *M

        New creates a new, empty metrics collector.

        func (*M) Count

        func (m *M) Count(name string, n int64)

          Count adds n to the current value of the counter named, defining the counter if it does not already exist.

          func (*M) CountAndSetMax

          func (m *M) CountAndSetMax(name string, n int64)

            CountAndSetMax adds n to the current value of the counter named, and also updates a max value tracker with the same name in a single step.

            func (*M) SetLabel

            func (m *M) SetLabel(name string, value interface{})

              SetLabel sets the specified label to value. If value == nil the label is removed from the set.

              func (*M) SetMaxValue

              func (m *M) SetMaxValue(name string, n int64)

                SetMaxValue sets the maximum value metric named to the greater of n and its current value, defining the value if it does not already exist.

                func (*M) Snapshot

                func (m *M) Snapshot(snap Snapshot)

                  Snapshot copies an atomic snapshot of the collected metrics into the non-nil fields of the provided snapshot value. Only the fields of snap that are not nil are snapshotted.

                  type Snapshot

                  type Snapshot struct {
                  	Counter  map[string]int64
                  	MaxValue map[string]int64
                  	Label    map[string]interface{}
                  }

                    A Snapshot represents a point-in-time snapshot of a metrics collector. The fields of this type are filled in by the Snapshot method of *M.

                    Source Files