-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
filelogreceiver panics when trace_flags is an empty string #20924
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Thanks for the report @bgranetzke, would you be interested in contributing a test case reproducing the problem? |
@atoulme Not sure if this is what you meant, but I cut a PR with a unit test which exercised the specific condition and then I fixed the cause. |
FYI: I was also able to reproduce the problem when I upgraded the collector version to 0.75.0
|
@bgranetzke Thanks for fixing this! Feel free to close this issue if it's in fact resolved. |
Component(s)
pkg/stanza
What happened?
Description
collector panics when trace parse operator encounters empty string for trace_flags
Steps to Reproduce
My use case is a regex operator which accounts for the log line optionally containing the trace/trace flags at the end.
Expected Result
parser gracefully does not try to add trace flags
Actual Result
Panic:
panic: runtime error: index out of range [0] with length 0 goroutine 177 [running]: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/adapter.convertInto(0xc047473140, {0x90?}) github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.70.0/adapter/converter.go:338 +0x2b5 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/adapter.convert(0xc000baef90?) github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.70.0/adapter/converter.go:284 +0x37 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/adapter.(*Converter).workerLoop(0xc000617680) github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.70.0/adapter/converter.go:167 +0x27b created by github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/adapter.(*Converter).Start github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza@v0.70.0/adapter/converter.go:118 +0xf5
panic line in current main:
https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/adapter/converter.go#L271
The root cause might be further upstream (passing an empty []byte instead of a nil), but I think some simple defensive programming here makes sense (add a len() check in addition to the nil check)
Collector version
0.70.0
Environment information
No response
OpenTelemetry Collector configuration
No response
Log output
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: