register std metrics once on init
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
21494e0e7a
commit
0e192d8a82
@ -288,6 +288,14 @@ func (m *prometheusMeter) Init(opts ...meter.Option) error {
|
|||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(&m.opts)
|
o(&m.opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if m.opts.WriteProcessMetrics || m.opts.WriteFDMetrics {
|
||||||
|
pc := collectors.NewProcessCollector(collectors.ProcessCollectorOpts{})
|
||||||
|
_ = m.set.Register(pc)
|
||||||
|
gc := collectors.NewGoCollector(collectors.WithGoCollectorRuntimeMetrics(collectors.GoRuntimeMetricsRule{Matcher: regexp.MustCompile("/.*")}))
|
||||||
|
_ = m.set.Register(gc)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,13 +305,6 @@ func (m *prometheusMeter) Write(w io.Writer, opts ...meter.Option) error {
|
|||||||
o(&options)
|
o(&options)
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.WriteProcessMetrics || options.WriteFDMetrics {
|
|
||||||
pc := collectors.NewProcessCollector(collectors.ProcessCollectorOpts{})
|
|
||||||
_ = m.set.Register(pc)
|
|
||||||
gc := collectors.NewGoCollector(collectors.WithGoCollectorRuntimeMetrics(collectors.GoRuntimeMetricsRule{Matcher: regexp.MustCompile("/.*")}))
|
|
||||||
_ = m.set.Register(gc)
|
|
||||||
}
|
|
||||||
|
|
||||||
g, ok := m.set.(prometheus.Gatherer)
|
g, ok := m.set.(prometheus.Gatherer)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("set type %T not prometheus.Gatherer", m.set)
|
return fmt.Errorf("set type %T not prometheus.Gatherer", m.set)
|
||||||
|
Loading…
Reference in New Issue
Block a user