-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[elasticsearchexporter] exporter panics when encoding non-string value scope attributes #37701
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
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
/label -needs-triage |
This seems to only affect raw and none mode, as ECS and OTel mapping mode uses other code paths. |
/label good-first-issue |
Hey folks, I'll take this if it's ok. |
I needed to change the config to reproduce the issue. I needed to change the mapping mode. For the record I used the following:
|
Thanks @AndersonQ ! |
…en-telemetry#40098) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Previously, the code attempted to cast scope attribute values to strings, leading to a panic when incompatible types were encountered. When mapping scope to attributes, instead of trying to cast them to string now it just creates a new Map for the attributes and copies the cope entries to the new map. This avoids any cast and preserves the original types. <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#37701 <!--Describe what testing was performed and which tests were added.--> #### Testing Run the exporter with the config that originally causes the panic, see config below. Running it on main will panic, running it on this PR will not panic. ``` ./bin/otelcontribcol_linux_amd64 --config otel-test.yaml ``` ``` receivers: hostmetrics: metadata_collection_interval: 1s scrapers: cpu: {} exporters: elasticsearch: mapping: mode: none endpoint: <redacted> user: <redacted> password: <redacted> flush: interval: 1s service: pipelines: logs: receivers: [hostmetrics] processors: [] exporters: [elasticsearch] ``` <!--Describe the documentation added.--> #### Documentation N/A <!--Please delete paragraphs that you did not use before submitting.-->
Component(s)
exporter/elasticsearch
What happened?
Description
The Elasticsearch exporter assumes all scope attribute values are strings, and will panic if they're not.
Steps to Reproduce
Run the collector with the attached config. Yes, use a logs pipeline with the hostmetrics receiver -- originally an accident on my part, but it triggers the bug.
Expected Result
The exporter should encode scope attribute values with the original type rather than coercing to a string.
Actual Result
The exporter panics.
Collector version
v0.119.0
Environment information
Environment
N/A
OpenTelemetry Collector configuration
Log output
Additional context
No response
The text was updated successfully, but these errors were encountered: