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

[receiver/httpcheck] refactor client length checking #31036

Conversation

tranngoclam
Copy link
Contributor

Description:

  • Fix typo (clentErr) in receiver/httpcheckreceiver.
  • Simplify slice length checking (a nil slice also has length zero).

Link to tracking Issue:

Testing:

Documentation:

@tranngoclam tranngoclam requested a review from a team February 5, 2024 15:24
Copy link

linux-foundation-easycla bot commented Feb 5, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@github-actions github-actions bot added the receiver/httpcheck HTTP Check receiver label Feb 5, 2024
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fixing the typo, please review & sign the CLA

@@ -46,12 +46,13 @@ func (h *httpcheckScraper) start(_ context.Context, host component.Host) (err er

// scrape connects to the endpoint and produces metrics based on the response
func (h *httpcheckScraper) scrape(ctx context.Context) (pmetric.Metrics, error) {
if h.clients == nil || len(h.clients) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a case where this change catches something that didn't used to be caught? If clients is nil, it returns the error, if the length is 0, it returns the error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's the same logic. The new change is to remove redundant checking. If a slice is nil then its length is also zero

@tranngoclam tranngoclam force-pushed the refactor/httpcheckreceiver-scraper branch from 9adf6ed to aaf8e9e Compare February 6, 2024 01:55
@tranngoclam
Copy link
Contributor Author

@codeboten can you review the PR again? Thanks

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 25, 2024
Copy link
Contributor

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
receiver/httpcheck HTTP Check receiver Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants