-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Count connector improperly handles non-string attributes #30314
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Thanks for reporting. I agree we need to handle other types as well. Any interest in submitting a fix for this? |
@djaglowski I would be happy to provide a fix and it seems mostly straightforward, however this one part that isn't immediately obvious. Is there a preferred way to handle the type of the default value: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/connector/countconnector/config.go#L51? |
That's a good point. Maybe we should define a type constraint which includes a fixed set of types which we would accept. It's not clear exactly which types we should support, but perhaps we could start with a somewhat limited list and go from there. |
I just ran into this bug today as well, with exactly the same scenario (http status code). For the type constraints, should we start with:
|
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
**Description:** Adding support for non string attributes in the count connector. I started working based on #30314 (comment), but it doesn't work. When I try to add the type constaint: ``` type Number interface { int64 | float64 } type AttributeConfig struct { Key string `mapstructure:"key"` DefaultValue Number `mapstructure:"default_value"` } ``` This causes the following error: ``` cannot use type Number outside a type constraint: interface contains type constraints ``` My idea was to introduce new fields `DefaultIntValue` and `DefaultFloatValue` to handle number types, let me know if this makes sense, if so, I will add documentation and finalize this PR. **Link to tracking Issue:** Fixes #30314. **Testing:** Added unit test **Documentation:** TODO
Component(s)
connector/count
What happened?
Description
When specifying attributes the connector will lose the client provided value if it is not a string, such as for
http.status_code
. The connector calls.Str()
without checking the type, which results in setting the value to an empty string if the original value is not a string.Steps to Reproduce
Count an attribute sent by clients as a non-string value:
Expected Result
The connector emits metrics with the counts split by
http.status_code
Actual Result
The connector emits metrics with
http.status_code
set to an empty string.Collector version
v0.91.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: