Skip to content

Commit

Permalink
Added option to disable cadvisor (#56)
Browse files Browse the repository at this point in the history
* made cadvisor optional

Signed-off-by: utukj <[email protected]>

* flipped cadvisor use and error message

Signed-off-by: utukj <[email protected]>

Signed-off-by: utukj <[email protected]>
  • Loading branch information
utukJ authored Nov 18, 2022
1 parent cbc7a9c commit 861932b
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions monitoring/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ type opt struct {
scrapeInterval time.Duration
customRegistry *prometheus.Registry
customPromImage string
useCadvisor bool
}

// WithScrapeInterval changes how often metrics are scrape by Prometheus. 5s by default.
Expand All @@ -220,12 +221,21 @@ func WithPrometheusImage(image string) Option {
}
}

func WithCadvisorDisabled() Option {
return func(o *opt) {
o.useCadvisor = false
}
}

type Option func(*opt)

// Start deploys monitoring service which deploys Prometheus that monitors all
// InstrumentedRunnable instances in an environment created with AsInstrumented.
func Start(env e2e.Environment, opts ...Option) (_ *Service, err error) {
opt := opt{scrapeInterval: 5 * time.Second}
opt := opt{
scrapeInterval: 5 * time.Second,
useCadvisor: true,
}
for _, o := range opts {
o(&opt)
}
Expand Down Expand Up @@ -271,9 +281,14 @@ func Start(env e2e.Environment, opts ...Option) (_ *Service, err error) {
}
env.AddListener(l)

c := newCadvisor(env, "cadvisor")
if err := e2e.StartAndWaitReady(c, p); err != nil {
return nil, errors.Wrap(err, "starting cadvisor and monitoring and waiting until ready")
if opt.useCadvisor {
c := newCadvisor(env, "cadvisor")
if err := e2e.StartAndWaitReady(c); err != nil {
return nil, errors.Wrap(err, "starting cadvisor and waiting until ready")
}
}
if err := e2e.StartAndWaitReady(p); err != nil {
return nil, errors.Wrap(err, "starting monitoring and waiting until ready")
}

select {
Expand Down

0 comments on commit 861932b

Please sign in to comment.