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

return concrete types! #34810

Closed
wants to merge 1 commit into from
Closed
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
27 changes: 9 additions & 18 deletions receiver/azuremonitorreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,46 +140,37 @@ func (s *azureScraper) getArmClientOptions() *arm.ClientOptions {
return &options
}

func (s *azureScraper) getArmClient() (armClient, error) {
client, err := s.armClientFunc(s.cfg.SubscriptionID, s.cred, s.armClientOptions)
return client, err
}

type metricsDefinitionsClientInterface interface {
NewListPager(resourceURI string, options *armmonitor.MetricDefinitionsClientListOptions) *runtime.Pager[armmonitor.MetricDefinitionsClientListResponse]
}

func (s *azureScraper) getMetricsDefinitionsClient() (metricsDefinitionsClientInterface, error) {
client, err := s.armMonitorDefinitionsClientFunc(s.cfg.SubscriptionID, s.cred, s.armClientOptions)
return client, err
}

type metricsValuesClient interface {
List(ctx context.Context, resourceURI string, options *armmonitor.MetricsClientListOptions) (
armmonitor.MetricsClientListResponse, error,
)
}

func (s *azureScraper) GetMetricsValuesClient() (metricsValuesClient, error) {
client, err := s.armMonitorMetricsClientFunc(s.cfg.SubscriptionID, s.cred, s.armClientOptions)
return client, err
}

func (s *azureScraper) start(_ context.Context, _ component.Host) (err error) {
if err = s.loadCredentials(); err != nil {
return err
}

s.armClientOptions = s.getArmClientOptions()
s.clientResources, err = s.getArmClient()
s.clientResources, err = s.armClientFunc(s.cfg.SubscriptionID, s.cred, s.armClientOptions)
if err != nil {
return err
}
s.clientMetricsDefinitions, err = s.getMetricsDefinitionsClient()

s.clientMetricsDefinitions, err = s.armMonitorDefinitionsClientFunc(s.cfg.SubscriptionID, s.cred, s.armClientOptions)
if err != nil {
return err
}
s.clientMetricsValues, err = s.GetMetricsValuesClient()

s.clientMetricsValues, err = s.armMonitorMetricsClientFunc(
s.cfg.SubscriptionID,
s.cred,
s.armClientOptions,
)
if err != nil {
return err
}
Expand Down
Loading