Browse Source

use cgroup cpu

master
andrey 5 months ago
parent
commit
29b2760db4
  1. 19
      cgroups/cpu.go

19
cgroups/cpu.go

@ -32,9 +32,9 @@ func WithControllers(ctrls ...Controller) Option {
// Option supports configuring optional settings for runtime metrics.
type Option func(*config)
func newConfig(controllers []Controller, opts ...Option) config {
func newConfig(opts ...Option) config {
cfg := config{
controllers: controllers,
controllers: []Controller{ControllerCPU},
provider: otel.GetMeterProvider(),
prefix: "cgroups.",
}
@ -179,20 +179,7 @@ func Start(group string, opts ...Option) (metric.Registration, error) {
return nil, fmt.Errorf("load:%w", err)
}
controllers, cerr := manager.Controllers()
if cerr != nil {
return nil, fmt.Errorf("controllers:%w", cerr)
}
ctrls := make([]Controller, 0, len(controllers))
for _, controller := range controllers {
ctrl, err := ParseController(controller)
if err == nil {
ctrls = append(ctrls, ctrl)
}
}
cfg := newConfig(ctrls, opts...)
cfg := newConfig(opts...)
cgr := cgroup{
meter: cfg.provider.Meter(

Loading…
Cancel
Save