use cgroup cpu

This commit is contained in:
andrey
2024-04-06 16:37:24 +03:00
parent a579343fc7
commit 29b2760db4

View File

@@ -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(