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/podman] Invalid stats error handler #9397

Closed
rogercoll opened this issue Apr 21, 2022 · 0 comments
Closed

[receiver/podman] Invalid stats error handler #9397

rogercoll opened this issue Apr 21, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@rogercoll
Copy link
Contributor

I was working on a new feature for the podman receiver and I noticed that if the containers stats API endpoint returns an error, the receiver panics:

2022-04-21T20:48:51.763+0200	error	podmanreceiver@v0.49.0/receiver.go:80	error fetching stats	{"kind": "receiver", "name": "podman_stats", "error": "json: cannot unmarshal object into Go struct field containerStatsReport.Error of type string"}
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/podmanreceiver.(*receiver).scrape
	github.com/open-telemetry/opentelemetry-collector-contrib/receiver/podmanreceiver@v0.49.0/receiver.go:80
go.opentelemetry.io/collector/receiver/scraperhelper.ScrapeFunc.Scrape
	go.opentelemetry.io/collector@v0.49.0/receiver/scraperhelper/scraper.go:32
go.opentelemetry.io/collector/receiver/scraperhelper.(*controller).scrapeMetricsAndReport
	go.opentelemetry.io/collector@v0.49.0/receiver/scraperhelper/scrapercontroller.go:195
go.opentelemetry.io/collector/receiver/scraperhelper.(*controller).startScraping.func1
	go.opentelemetry.io/collector@v0.49.0/receiver/scraperhelper/scrapercontroller.go:173
2022-04-21T20:48:51.763+0200	error	scraperhelper/scrapercontroller.go:198	Error scraping metrics	{"kind": "receiver", "name": "podman_stats", "error": "json: cannot unmarshal object into Go struct field containerStatsReport.Error of type string", "scraper": "podman_stats"}
go.opentelemetry.io/collector/receiver/scraperhelper.(*controller).scrapeMetricsAndReport
	go.opentelemetry.io/collector@v0.49.0/receiver/scraperhelper/scrapercontroller.go:198
go.opentelemetry.io/collector/receiver/scraperhelper.(*controller).startScraping.func1
	go.opentelemetry.io/collector@v0.49.0/receiver/scraperhelper/scrapercontroller.go:173

The error is because the actual structure used to unmarshal the api response:

type containerStatsReport struct {
	Error string
	Stats []containerStats
}

As the Podman API documentation describes, the Error is a structure with three attributes:
https://docs.podman.io/en/latest/_static/api.html#operation/ContainersStatsAllLibpod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant