MCPcopy Create free account
hub / github.com/coder/coder / Commit

Method Commit

coderd/prometheusmetrics/collector.go:78–94  ·  view source on GitHub ↗

Commit will set the internal value as the cached value to return from "Collect()". The internal metric value is completely reset, so the caller should expect the gauge to be empty for the next 'WithLabelValues' values.

()

Source from the content-addressed store, hash-verified

76// The internal metric value is completely reset, so the caller should expect
77// the gauge to be empty for the next 'WithLabelValues' values.
78func (v *CachedGaugeVec) Commit() {
79 v.m.Lock()
80 defer v.m.Unlock()
81
82 v.gaugeVec.Reset()
83 for _, record := range v.records {
84 g := v.gaugeVec.WithLabelValues(record.labelValues...)
85 switch record.operation {
86 case VectorOperationAdd:
87 g.Add(record.value)
88 case VectorOperationSet:
89 g.Set(record.value)
90 }
91 }
92
93 v.records = nil
94}

Calls 6

WithLabelValuesMethod · 0.80
ResetMethod · 0.65
AddMethod · 0.65
SetMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45