Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ws-daemon] Remove gitpod_ws_daemon_workspace_cpu_limit_sec metric #5444

Merged
merged 1 commit into from
Aug 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions components/ws-daemon/pkg/resources/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"container/ring"
"context"
"errors"
"fmt"
"os"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -44,9 +43,6 @@ type Controller struct {
processPriorities map[ProcessType]int

Prometheus prometheus.Registerer
metrics struct {
CPULimit *prometheus.CounterVec
}

mu sync.RWMutex
stopOnce sync.Once
Expand Down Expand Up @@ -141,31 +137,13 @@ func NewController(containerID, instanceID string, cgroupPath string, opts ...Co
}
gov.cpuExpenditures = ring.New(sampleCount)

err = gov.registerPrometheusGauges()
if err != nil {
return nil, xerrors.Errorf("cannot register Prometheus metrics: %w", err)
}

if gov.ControlPeriod%gov.SamplingPeriod != 0 {
return nil, xerrors.Errorf("control period must be a multiple of sampling period")
}

return gov, nil
}

func (gov *Controller) registerPrometheusGauges() (err error) {
gov.metrics.CPULimit = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "workspace_cpu_limit_sec",
Help: "Time spent in each CPU limit",
}, []string{"limit"})
err = gov.Prometheus.Register(gov.metrics.CPULimit)
if err != nil {
log.WithError(err).Warn("cannot register Prometheus metric")
}

return nil
}

// Start actually starts governing. This function is meant to be called as a Go-routine.
func (gov *Controller) Start(ctx context.Context) {
t := time.NewTicker(gov.SamplingPeriod)
Expand Down Expand Up @@ -359,7 +337,6 @@ func (gov *Controller) enforceCPULimit(limit int64) (didChange bool, err error)

periodToMilliseconds := (time.Duration(period) * time.Microsecond).Milliseconds()
newQuota := limit * (10 /* milli-jiffie per jiffie */) * periodToMilliseconds
gov.metrics.CPULimit.WithLabelValues(fmt.Sprintf("%d", limit)).Add(gov.SamplingPeriod.Seconds())

if newQuota == currentQuota {
return false, nil
Expand Down