MCPcopy
hub / github.com/prometheus/client_golang / Metric

Interface Metric

prometheus/metric.go:33–59  ·  prometheus/metric.go::Metric

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.

Source from the content-addressed store, hash-verified

31// Prometheus. Implementations of Metric in this package are Gauge, Counter,
32// Histogram, Summary, and Untyped.
33type 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

Callers 16

DescribeMethod · 0.65
TestBatchHistogramFunction · 0.65
DescMethod · 0.65
TestGoCollectorMemStatsFunction · 0.65
TestGoCollectorGCFunction · 0.65
TestTimerObserveFunction · 0.65

Implementers 14

valueFuncprometheus/value.go
constMetricprometheus/value.go
batchHistogramprometheus/go_collector_latest.go
wrappingMetricprometheus/wrap.go
counterprometheus/counter.go
Infoprometheus/example_metricvec_test.go
invalidMetricprometheus/metric.go
histogramprometheus/histogram.go
constHistogramprometheus/histogram.go
constNativeHistogramprometheus/histogram.go
summaryprometheus/summary.go
noObjectivesSummaryprometheus/summary.go

Calls

no outgoing calls

Tested by

no test coverage detected