From 926ff32b8da2d104a2cf15b1fce93126cb950980 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Thu, 9 Jan 2025 16:14:04 +0100 Subject: [PATCH] automatically set service name --- .../k8sattributesprocessor/internal/kube/client.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/processor/k8sattributesprocessor/internal/kube/client.go b/processor/k8sattributesprocessor/internal/kube/client.go index 8effe2037e1d..df84c94d3970 100644 --- a/processor/k8sattributesprocessor/internal/kube/client.go +++ b/processor/k8sattributesprocessor/internal/kube/client.go @@ -512,10 +512,16 @@ func (c *WatchClient) extractPodAttributes(pod *api_v1.Pod) (map[string]string, serviceNames[conventions.AttributeK8SReplicaSetName] = ref.Name } if c.Rules.DeploymentName { - tags[conventions.AttributeK8SDeploymentName] = c.deploymentName(ref) + name := c.deploymentName(ref) + if name != "" { + tags[conventions.AttributeK8SDeploymentName] = name + } } if c.Rules.OperatorRules.Enabled { - serviceNames[conventions.AttributeK8SDeploymentName] = c.deploymentName(ref) + name := c.deploymentName(ref) + if name != "" { + serviceNames[conventions.AttributeK8SDeploymentName] = name + } } if c.Rules.DeploymentUID { if replicaset, ok := c.getReplicaSet(string(ref.UID)); ok {