Collector is the interface implemented by anything that can be used by Prometheus to collect metrics. A Collector has to be registered for collection. See Registerer.Register. The stock metrics provided by this package (Gauge, Counter, Summary, Histogram, Untyped) are also Collectors (which only ev
| 25 | // (i.e. collection of multiple instances of the same Metric but with different |
| 26 | // label values) like GaugeVec or SummaryVec, and the ExpvarCollector. |
| 27 | type Collector interface { |
| 28 | // Describe sends the super-set of all possible descriptors of metrics |
| 29 | // collected by this Collector to the provided channel and returns once |
| 30 | // the last descriptor has been sent. The sent descriptors fulfill the |
| 31 | // consistency and uniqueness requirements described in the Desc |
| 32 | // documentation. |
| 33 | // |
| 34 | // It is valid if one and the same Collector sends duplicate |
| 35 | // descriptors. Those duplicates are simply ignored. However, two |
| 36 | // different Collectors must not send duplicate descriptors. |
| 37 | // |
| 38 | // Sending no descriptor at all marks the Collector as “unchecked”, |
| 39 | // i.e. no checks will be performed at registration time, and the |
| 40 | // Collector may yield any Metric it sees fit in its Collect method. |
| 41 | // |
| 42 | // This method idempotently sends the same descriptors throughout the |
| 43 | // lifetime of the Collector. It may be called concurrently and |
| 44 | // therefore must be implemented in a concurrency safe way. |
| 45 | // |
| 46 | // If a Collector encounters an error while executing this method, it |
| 47 | // must send an invalid descriptor (created with NewInvalidDesc) to |
| 48 | // signal the error to the registry. |
| 49 | Describe(chan<- *Desc) |
| 50 | // Collect is called by the Prometheus registry when collecting |
| 51 | // metrics. The implementation sends each collected metric via the |
| 52 | // provided channel and returns once the last metric has been sent. The |
| 53 | // descriptor of each sent metric is one of those returned by Describe |
| 54 | // (unless the Collector is unchecked, see above). Returned metrics that |
| 55 | // share the same descriptor must differ in their variable label |
| 56 | // values. |
| 57 | // |
| 58 | // This method may be called concurrently and must therefore be |
| 59 | // implemented in a concurrency safe way. Blocking occurs at the expense |
| 60 | // of total performance of rendering all registered metrics. Ideally, |
| 61 | // Collector implementations support concurrent readers. |
| 62 | Collect(chan<- Metric) |
| 63 | } |
| 64 | |
| 65 | // DescribeByCollect is a helper to implement the Describe method of a custom |
| 66 | // Collector. It collects the metrics from the provided Collector and sends |
no outgoing calls
no test coverage detected