[processor/k8sattributes] attributes retrieved from related K8s objects not applied if original attributes contains empty value #36373
Labels
bug
Something isn't working
needs triage
New item requiring triage
processor/k8sattributes
k8s Attributes processor
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: