mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-19 08:07:58 +02:00
Disable Prometheus metrics by default (#331)
This commit is contained in:
@@ -61,6 +61,7 @@ type Controller struct {
|
||||
maxWorkersPerLicense uint
|
||||
experimentalRPCV2 bool
|
||||
pingInterval time.Duration
|
||||
prometheusMetrics bool
|
||||
|
||||
sshListenAddr string
|
||||
sshSigner ssh.Signer
|
||||
@@ -122,7 +123,7 @@ func New(opts ...Option) (*Controller, error) {
|
||||
|
||||
// Instantiate the scheduler
|
||||
controller.scheduler, err = scheduler.NewScheduler(store, controller.workerNotifier,
|
||||
controller.workerOfflineTimeout, controller.logger)
|
||||
controller.workerOfflineTimeout, controller.prometheusMetrics, controller.logger)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -65,6 +65,12 @@ func WithPingInterval(pingInterval time.Duration) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func WithPrometheusMetrics() Option {
|
||||
return func(controller *Controller) {
|
||||
controller.prometheusMetrics = true
|
||||
}
|
||||
}
|
||||
|
||||
func WithLogger(logger *zap.Logger) Option {
|
||||
return func(controller *Controller) {
|
||||
controller.logger = logger.Sugar()
|
||||
|
||||
@@ -49,6 +49,7 @@ type Scheduler struct {
|
||||
workerOfflineTimeout time.Duration
|
||||
logger *zap.SugaredLogger
|
||||
schedulingRequested chan bool
|
||||
prometheusMetrics bool
|
||||
|
||||
schedulingTimeHistogram metric.Float64Histogram
|
||||
}
|
||||
@@ -57,6 +58,7 @@ func NewScheduler(
|
||||
store storepkg.Store,
|
||||
notifier *notifier.Notifier,
|
||||
workerOfflineTimeout time.Duration,
|
||||
prometheusMetrics bool,
|
||||
logger *zap.SugaredLogger,
|
||||
) (*Scheduler, error) {
|
||||
scheduler := &Scheduler{
|
||||
@@ -65,6 +67,7 @@ func NewScheduler(
|
||||
workerOfflineTimeout: workerOfflineTimeout,
|
||||
logger: logger,
|
||||
schedulingRequested: make(chan bool, 1),
|
||||
prometheusMetrics: prometheusMetrics,
|
||||
}
|
||||
|
||||
// Metrics
|
||||
@@ -104,7 +107,9 @@ func (scheduler *Scheduler) Run() {
|
||||
|
||||
if err != nil {
|
||||
scheduler.logger.Errorf("Failed to schedule VMs: %v", err)
|
||||
} else {
|
||||
}
|
||||
|
||||
if scheduler.prometheusMetrics {
|
||||
schedulerLoopIterationStat.Inc()
|
||||
}
|
||||
}
|
||||
@@ -395,12 +400,14 @@ func (scheduler *Scheduler) healthCheckingLoopIteration() error {
|
||||
}
|
||||
|
||||
// Update metrics
|
||||
workers, err := txn.ListWorkers()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if scheduler.prometheusMetrics {
|
||||
workers, err := txn.ListWorkers()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
scheduler.reportStats(workers, vms)
|
||||
scheduler.reportStats(workers, vms)
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user