Skip to content

Commit

Permalink
Apply changes suggested by @bogdandrutu in open-telemetry#30135
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Dec 22, 2023
1 parent cdb70a4 commit 8cc77b6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions receiver/prometheusreceiver/config.go
Original file line number Diff line number Diff line change
@@ -99,11 +99,9 @@ func (cfg *Config) Validate() error {
return errors.New("no Prometheus scrape_configs or target_allocator set")
}

if promConfig != nil {
err := cfg.validatePromConfig(promConfig)
if err != nil {
return err
}
err := validatePromConfig(promConfig)
if err != nil {
return err
}

if cfg.TargetAllocator != nil {
@@ -115,7 +113,10 @@ func (cfg *Config) Validate() error {
return nil
}

func (cfg *Config) validatePromConfig(promConfig *promconfig.Config) error {
func validatePromConfig(promConfig *promconfig.Config) error {
if promConfig == nil {
return nil
}
// Reject features that Prometheus supports but that the receiver doesn't support:
// See:
// * https://github.com/open-telemetry/opentelemetry-collector/issues/3863
@@ -142,7 +143,7 @@ func (cfg *Config) validatePromConfig(promConfig *promconfig.Config) error {
return fmt.Errorf("unsupported features:\n\t%s", strings.Join(unsupportedFeatures, "\n\t"))
}

for _, sc := range cfg.PrometheusConfig.ScrapeConfigs {
for _, sc := range promConfig.ScrapeConfigs {
if sc.HTTPClientConfig.Authorization != nil {
if err := checkFile(sc.HTTPClientConfig.Authorization.CredentialsFile); err != nil {
return fmt.Errorf("error checking authorization credentials file %q: %w", sc.HTTPClientConfig.Authorization.CredentialsFile, err)

0 comments on commit 8cc77b6

Please sign in to comment.