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/hostmetrics] should report scraper that failed in case of error #35814

Closed
pjanotti opened this issue Oct 15, 2024 · 3 comments · Fixed by #35837
Closed

[receiver/hostmetrics] should report scraper that failed in case of error #35814

pjanotti opened this issue Oct 15, 2024 · 3 comments · Fixed by #35837
Labels

Comments

@pjanotti
Copy link
Contributor

Component(s)

receiver/hostmetrics

Is your feature request related to a problem? Please describe.

In case of error the receiver/hostmetrics doesn't report which scraper failed, e.g.:

1729010081650,"2024-10-15T16:34:41.650Z	error	scraperhelper/scrapercontroller.go:205	Error scraping metrics	{""kind"": ""receiver"", ""name"": ""hostmetrics"", ""data_type"": ""metrics"", ""error"": ""failed to read usage at /boot/efi: no such file or directory"", ""scraper"": ""hostmetrics""}"
1729010081650,go.opentelemetry.io/collector/receiver/scraperhelper.(*controller).scrapeMetricsAndReport
1729010081650,	go.opentelemetry.io/collector/receiver@v0.111.0/scraperhelper/scrapercontroller.go:205
1729010081650,go.opentelemetry.io/collector/receiver/scraperhelper.(*controller).startScraping.func1
1729010081650,	go.opentelemetry.io/collector/receiver@v0.111.0/scraperhelper/scrapercontroller.go:181

Describe the solution you'd like

The error message should include the scraper name so the user can consider disabling it or changing some config setting.

Describe alternatives you've considered

No response

Additional context

No response

@pjanotti pjanotti added enhancement New feature or request needs triage New item requiring triage labels Oct 15, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@braydonk
Copy link
Contributor

I'm not sure why, but all the scraper creation code uses hostmetrics (the type from the hostmetricsreceiver metadata package) rather than its own name. I'm not sure why it's done that way as it's before my time. @dmitryax any reason we shouldn't just adjust that code to use the respective scraper names instead of hostmetrics?

@dmitryax
Copy link
Member

I agree. We should mention the scraper that failed

@atoulme atoulme removed the needs triage New item requiring triage label Oct 16, 2024
dmitryax pushed a commit that referenced this issue Oct 24, 2024
#### Description
This PR changes each scraper's factory to create a scraper with the
scraper's name. This is to ensure that logs from the `scrapercontroller`
will contain the name of the scraper.

#### Link to tracking issue
Fixes #35814 

#### Testing
New unit tests

Built the collector with `cpu` scraper modified to immediately return an
error and got the following message:
```
2024-10-16T14:58:46.396Z        error   scraperhelper/scrapercontroller.go:205  Error scraping metrics  {"kind": "receiver", "name": "hostmetrics", "data_type": "metrics", "error": "hi i failed", "scraper": "cpu"}
```
sbylica-splunk pushed a commit to sbylica-splunk/opentelemetry-collector-contrib that referenced this issue Dec 17, 2024
…emetry#35837)

#### Description
This PR changes each scraper's factory to create a scraper with the
scraper's name. This is to ensure that logs from the `scrapercontroller`
will contain the name of the scraper.

#### Link to tracking issue
Fixes open-telemetry#35814 

#### Testing
New unit tests

Built the collector with `cpu` scraper modified to immediately return an
error and got the following message:
```
2024-10-16T14:58:46.396Z        error   scraperhelper/scrapercontroller.go:205  Error scraping metrics  {"kind": "receiver", "name": "hostmetrics", "data_type": "metrics", "error": "hi i failed", "scraper": "cpu"}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants