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

Function NewGauge

prometheus/gauge.go:78–88  ·  view source on GitHub ↗

NewGauge creates a new Gauge based on the provided GaugeOpts. The returned implementation is optimized for a fast Set method. If you have a choice for managing the value of a Gauge via Set vs. Inc/Dec/Add/Sub, pick the former. For example, the Inc method of the returned Gauge is slower than the Inc

(opts GaugeOpts)

Source from the content-addressed store, hash-verified

76// scenarios for Gauges and Counters, where the former tends to be Set-heavy and
77// the latter Inc-heavy.
78func NewGauge(opts GaugeOpts) Gauge {
79 desc := NewDesc(
80 BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
81 opts.Help,
82 nil,
83 opts.ConstLabels,
84 )
85 result := &gauge{desc: desc, labelPairs: desc.constLabelPairs}
86 result.init(result) // Init self-collection.
87 return result
88}
89
90type gauge struct {
91 // valBits contains the bits of the represented float64 value. It has

Callers 15

ExampleGaugeFunction · 0.92
TestNewMultiTRegistryFunction · 0.92
InstrumentMetricHandlerFunction · 0.92
makeInstrumentedClientFunction · 0.92
makeInstrumentedHandlerFunction · 0.92
TestPushFunction · 0.92
ExamplePusher_PushFunction · 0.92

Calls 3

NewDescFunction · 0.85
BuildFQNameFunction · 0.85
initMethod · 0.80

Tested by 15

ExampleGaugeFunction · 0.74
TestNewMultiTRegistryFunction · 0.74
makeInstrumentedClientFunction · 0.74
makeInstrumentedHandlerFunction · 0.74
TestPushFunction · 0.74
ExamplePusher_PushFunction · 0.74
TestToFloat64Function · 0.74
TestTimerObserveFunction · 0.56