For convenient use with xxhash. A Metric models a single sample value with its meta data being exported to Prometheus. Implementations of Metric in this package are Gauge, Counter, Histogram, Summary, and Untyped.
| 31 | // Prometheus. Implementations of Metric in this package are Gauge, Counter, |
| 32 | // Histogram, Summary, and Untyped. |
| 33 | type Metric interface { |
| 34 | // Desc returns the descriptor for the Metric. This method idempotently |
| 35 | // returns the same descriptor throughout the lifetime of the |
| 36 | // Metric. The returned descriptor is immutable by contract. A Metric |
| 37 | // unable to describe itself must return an invalid descriptor (created |
| 38 | // with NewInvalidDesc). |
| 39 | Desc() *Desc |
| 40 | // Write encodes the Metric into a "Metric" Protocol Buffer data |
| 41 | // transmission object. |
| 42 | // |
| 43 | // Metric implementations must observe concurrency safety as reads of |
| 44 | // this metric may occur at any time, and any blocking occurs at the |
| 45 | // expense of total performance of rendering all registered |
| 46 | // metrics. Ideally, Metric implementations should support concurrent |
| 47 | // readers. |
| 48 | // |
| 49 | // While populating dto.Metric, it is the responsibility of the |
| 50 | // implementation to ensure validity of the Metric protobuf (like valid |
| 51 | // UTF-8 strings or syntactically valid metric and label names). It is |
| 52 | // recommended to sort labels lexicographically. Callers of Write should |
| 53 | // still make sure of sorting if they depend on it. |
| 54 | Write(*dto.Metric) error |
| 55 | // TODO(beorn7): The original rationale of passing in a pre-allocated |
| 56 | // dto.Metric protobuf to save allocations has disappeared. The |
| 57 | // signature of this method should be changed to "Write() (*dto.Metric, |
| 58 | // error)". |
| 59 | } |
| 60 | |
| 61 | // Opts bundles the options for creating most Metric types. Each metric |
| 62 | // implementation XXX has its own XXXOpts type, but in most cases, it is just |
no outgoing calls
no test coverage detected