func populateMetric( t ValueType, v float64, labelPairs []*dto.LabelPair, m *dto.Metric, ) { m.Label = labelPairs switch t { case CounterValue: m.Counter = &dto.Counter{Value: proto.Float64(v)} case GaugeValue: m.Gauge = &dto.Gauge{Value: proto.Float64(v)} case UntypedValue: m.Untyped = &dto.Untyped{Value: proto.Float64(v)} default: panic(fmt.Errorf("encountered unknown type %v", t)) } }
func (cm *CallbackMetric) Write(m *dto.Metric) error { m.Untyped = &dto.Untyped{Value: proto.Float64(cm.callback())} return nil }
func (cm *CallbackMetric) Write(m *dto.Metric) { m.Untyped = &dto.Untyped{Value: proto.Float64(cm.callback())} }