func init() { prometheus.MustRegister(prometheus.NewCounterFunc(prometheus.CounterOpts{ Name: "lg_info_lines", Help: "Number of entries lg error lines logged", }, func() float64 { return float64(lg.Stats.Info.Lines()) })) prometheus.MustRegister(prometheus.NewCounterFunc(prometheus.CounterOpts{ Name: "lg_warning_lines", Help: "Number of entries lg error lines logged", }, func() float64 { return float64(lg.Stats.Warning.Lines()) })) prometheus.MustRegister(prometheus.NewCounterFunc(prometheus.CounterOpts{ Name: "lg_error_lines", Help: "Number of entries lg error lines logged", }, func() float64 { return float64(lg.Stats.Error.Lines()) })) }
func (m *metric) init() error { name := m.Measurable.MsName() mangledName := mangleName(name) opts := prometheus.Opts{ Name: mangledName, Help: name, } switch m.Measurable.MsType() { case measurable.CounterType: mi, ok := m.Measurable.(interface { MsInt64() int64 }) if !ok { return errNotSupported } m.Metric = prometheus.NewCounterFunc(prometheus.CounterOpts(opts), func() float64 { return float64(mi.MsInt64()) }) case measurable.GaugeType: mi, ok := m.Measurable.(interface { MsInt64() int64 }) if !ok { return errNotSupported } m.Metric = prometheus.NewGaugeFunc(prometheus.GaugeOpts(opts), func() float64 { return float64(mi.MsInt64()) }) default: return errNotSupported } return nil }