Skip to content

Commit

Permalink
make private
Browse files Browse the repository at this point in the history
Signed-off-by: zachaller <[email protected]>
  • Loading branch information
zachaller committed Jul 25, 2023
1 parent d4e2066 commit a39f407
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions metricproviders/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
type Provider struct {
api v1.API
logCtx log.Entry
Timeout time.Duration
timeout time.Duration
}

// Type indicates provider is a prometheus provider
Expand All @@ -60,7 +60,7 @@ func (p *Provider) Run(run *v1alpha1.AnalysisRun, metric v1alpha1.Metric) v1alph
}

//TODO(dthomson) make timeout configurable
ctx, cancel := context.WithTimeout(context.Background(), p.Timeout)
ctx, cancel := context.WithTimeout(context.Background(), p.timeout)
defer cancel()

response, warnings, err := p.api.Query(ctx, metric.Provider.Prometheus.Query, time.Now())
Expand Down Expand Up @@ -146,7 +146,7 @@ func NewPrometheusProvider(api v1.API, logCtx log.Entry, metric v1alpha1.Metric)
}

if metric.Provider.Prometheus == nil || metric.Provider.Prometheus.Timeout == nil {
provider.Timeout = 30 * time.Second
provider.timeout = 30 * time.Second
return provider, nil
}

Expand All @@ -156,7 +156,7 @@ func NewPrometheusProvider(api v1.API, logCtx log.Entry, metric v1alpha1.Metric)
return nil, errors.New("prometheus timeout should not be negative")
}

provider.Timeout = time.Duration(*metricTimeout * int64(time.Second))
provider.timeout = time.Duration(*metricTimeout * int64(time.Second))
return provider, nil
}

Expand Down
2 changes: 1 addition & 1 deletion metricproviders/prometheus/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestType(t *testing.T) {
p, err := NewPrometheusProvider(mock, e, metric)
assert.NoError(t, err)
assert.Equal(t, ProviderType, p.Type())
assert.Equal(t, p.Timeout, time.Duration(timeout*int64(time.Second)))
assert.Equal(t, p.timeout, time.Duration(timeout*int64(time.Second)))
}

func TestRunSuccessfully(t *testing.T) {
Expand Down

0 comments on commit a39f407

Please sign in to comment.