Skip to content
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

[k8sattributesprocessor] Fall back to only container in pod in case no container name/id has been specified in the incoming resource attributes #36844

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

bacherfl
Copy link
Contributor

@bacherfl bacherfl commented Dec 16, 2024

Description

This PR adds a fallback logic to the processor by adding the container attributes for an incoming resource without the container name/id being explicitly set, provided the related pod only contains one container. If there are more than one container in a pod, the container name/id still have to be set explicitly.

Link to tracking issue

Fixes #34189

Testing

Added unit tests

Documentation

Adapted the readme to reflect the changes made in this PR

@bacherfl bacherfl marked this pull request as ready for review December 16, 2024 13:34
@bacherfl bacherfl requested a review from a team as a code owner December 16, 2024 13:34
@@ -227,7 +227,19 @@ func (kp *kubernetesprocessor) addContainerAttributes(attrs pcommon.Map, pod *ku
return
}
default:
return
switch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just add those two cases just parallel to the cases outside, no need to be nested into a default case, which is clearer?

Signed-off-by: Florian Bacher <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
processor/k8sattributes k8s Attributes processor
Projects
None yet
4 participants