-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[processor/k8sattributes] attributes retrieved from related K8s objects not applied if original attributes contains empty value #36373
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
I created a draft PR to outline the changes of the behavior: #36466 |
Thank's @bacherfl! I wonder if this logic should be configurable though ( I'm not sure how possible that would be though for someone to really want to preserve an empty value specially when these attributes are about K8s objects that cannot really be empty at first place 🤔 . Would love to know what code-owners think here. |
Good point regarding an option for that behaviour - let's wait on the code owner's opinion, but it might make sense to make this configurable |
I think we should treat |
thank you for the feedback @TylerHelmuth - in that case, the PR I created should be ready to review |
…bject if original value is empty (open-telemetry#36466) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This PR extends the previous check whether an attribute value has not been present with a check for an empty value in the original resource attributes. This way, attributes, such as `k8s.namespace.name` will be set based on the retrieved kubernetes resource also if the original value has been set to e.g. an empty string <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#36373 <!--Describe what testing was performed and which tests were added.--> #### Testing Added unit tests --------- Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com> Co-authored-by: Christos Markou <chrismarkou92@gmail.com>
…bject if original value is empty (open-telemetry#36466) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This PR extends the previous check whether an attribute value has not been present with a check for an empty value in the original resource attributes. This way, attributes, such as `k8s.namespace.name` will be set based on the retrieved kubernetes resource also if the original value has been set to e.g. an empty string <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#36373 <!--Describe what testing was performed and which tests were added.--> #### Testing Added unit tests --------- Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com> Co-authored-by: Christos Markou <chrismarkou92@gmail.com>
Component(s)
processor/k8sattributes
What happened?
Description
The
k8sattributes
processor currently checks if the original resource attributes contain a value for a given key, before applying an attribute. E.g. after retrieving the namespace information for a resource, it checks if the resource already has a value fork8s.namespace.name
, before setting the value of that attribute to that of the related namespace:opentelemetry-collector-contrib/processor/k8sattributesprocessor/processor.go
Line 167 in c06be6d
This avoids overwriting attributes that have been explicitly set previously.
However, if one of the attributes (e.g.
k8s.namespace.name
) is set to an empty value, this also leads to the namespace not being set by the processor. Therefore I would like to raise the question if in this case, the processor should add the attribute value retrieved from the related k8s object, or if the original, empty value should also not be modified in such a case?In my opinion, empty values should be treated the same way as non-existing values, and the processor should set the value, but I'd be interested in other opinions as well.
Steps to Reproduce
Deploy the collector in a K8s cluster with the following config
config.yaml
And send traffic to the collector, e.g. by creating a deployment with the
telemetrygen
cli, and add an emptyk8s.namespace.name
attribute to the generated traces:Expected Result
The exported traces should contain the resource attribute
k8s.namespace.name=e2ek8senrichment
Actual Result
The exported traces contain an empty value for the attribute
k8s.namespace.name
Collector version
v0.113.0
Environment information
Environment
OS: kind cluster on macOS
Compiler(if manually compiled): (e.g., "go 14.2")
OpenTelemetry Collector configuration
Log output
No response
Additional context
I'm already working on a fix for this, and will create the PR if the code owners agree with the proposed change
The text was updated successfully, but these errors were encountered: