diff --git a/docs/sources/metrics.md b/docs/sources/metrics.md index b13ca1588..de3a1233a 100644 --- a/docs/sources/metrics.md +++ b/docs/sources/metrics.md @@ -50,16 +50,17 @@ In order to configure which attributes to show or which attributes to hide, chec | Application (all) | `http.request.method` | shown | | Application (all) | `http.response.status_code` | shown | | Application (all) | `http.route` | shown if `routes` configuration section exists | -| Application (all) | `k8s.daemonset.name` | shown if network metrics are enabled | -| Application (all) | `k8s.deployment.name` | shown if network metrics are enabled | -| Application (all) | `k8s.namespace.name` | shown if network metrics are enabled | -| Application (all) | `k8s.node.name` | shown if network metrics are enabled | -| Application (all) | `k8s.pod.name` | shown if network metrics are enabled | -| Application (all) | `k8s.pod.start_time` | shown if network metrics are enabled | -| Application (all) | `k8s.pod.uid` | shown if network metrics are enabled | -| Application (all) | `k8s.replicaset.name` | shown if network metrics are enabled | -| Application (all) | `k8s.statefulset.name` | shown if network metrics are enabled | -| Application (all) | `k8s.cluster.name` | shown if network metrics are enabled | +| Application (all) | `k8s.daemonset.name` | shown if kubernetes metadata is enabled | +| Application (all) | `k8s.deployment.name` | shown if kubernetes metadata is enabled | +| Application (all) | `k8s.namespace.name` | shown if kubernetes metadata is enabled | +| Application (all) | `k8s.node.name` | shown if kubernetes metadata is enabled | +| Application (all) | `k8s.owner.name` | shown if kubernetes metadata is enabled | +| Application (all) | `k8s.pod.name` | shown if kubernetes metadata is enabled | +| Application (all) | `k8s.pod.start_time` | shown if kubernetes metadata is enabled | +| Application (all) | `k8s.pod.uid` | shown if kubernetes metadata is enabled | +| Application (all) | `k8s.replicaset.name` | shown if kubernetes metadata is enabled | +| Application (all) | `k8s.statefulset.name` | shown if kubernetes metadata is enabled | +| Application (all) | `k8s.cluster.name` | shown if kubernetes metadata is enabled | | Application (all) | `service.name` | shown | | Application (all) | `service.namespace` | shown | | Application (all) | `target.instance` | shown | diff --git a/pkg/transform/k8s.go b/pkg/transform/k8s.go index 0e3d3589a..554c520ec 100644 --- a/pkg/transform/k8s.go +++ b/pkg/transform/k8s.go @@ -135,6 +135,7 @@ func (md *metadataDecorator) appendMetadata(span *request.Span, info *kube.PodIn span.ServiceID.Metadata[attr.Name(info.Owner.LabelName)] = info.Owner.Name topOwner := info.Owner.TopOwner() span.ServiceID.Metadata[attr.Name(topOwner.LabelName)] = topOwner.Name + span.ServiceID.Metadata[attr.K8sOwnerName] = topOwner.Name } // override hostname by the Pod name span.ServiceID.HostName = info.Name diff --git a/test/integration/k8s/common/k8s_metrics_testfuncs.go b/test/integration/k8s/common/k8s_metrics_testfuncs.go index eddd36964..c99432bf8 100644 --- a/test/integration/k8s/common/k8s_metrics_testfuncs.go +++ b/test/integration/k8s/common/k8s_metrics_testfuncs.go @@ -121,6 +121,7 @@ func FeatureHTTPMetricsDecoration(manifest string) features.Feature { "k8s_node_name": ".+-control-plane$", "k8s_pod_uid": UUIDRegex, "k8s_pod_start_time": TimeRegex, + "k8s_owner_name": "^testserver$", "k8s_deployment_name": "^testserver$", "k8s_replicaset_name": "^testserver-", "k8s_cluster_name": "^beyla$", @@ -163,6 +164,7 @@ func FeatureGRPCMetricsDecoration(manifest string) features.Feature { "k8s_node_name": ".+-control-plane$", "k8s_pod_uid": UUIDRegex, "k8s_pod_start_time": TimeRegex, + "k8s_owner_name": "^testserver$", "k8s_deployment_name": "^testserver$", "k8s_replicaset_name": "^testserver-", "k8s_cluster_name": "^beyla$", diff --git a/test/integration/k8s/daemonset/k8s_daemonset_traces_test.go b/test/integration/k8s/daemonset/k8s_daemonset_traces_test.go index e678e0c41..81803c185 100644 --- a/test/integration/k8s/daemonset/k8s_daemonset_traces_test.go +++ b/test/integration/k8s/daemonset/k8s_daemonset_traces_test.go @@ -70,6 +70,7 @@ func TestBasicTracing(t *testing.T) { {Key: "k8s.node.name", Type: "string", Value: ".+-control-plane$"}, {Key: "k8s.pod.uid", Type: "string", Value: k8s.UUIDRegex}, {Key: "k8s.pod.start_time", Type: "string", Value: k8s.TimeRegex}, + {Key: "k8s.owner.name", Type: "string", Value: "^otherinstance$"}, {Key: "k8s.deployment.name", Type: "string", Value: "^otherinstance$"}, {Key: "k8s.namespace.name", Type: "string", Value: "^default$"}, {Key: "k8s.cluster.name", Type: "string", Value: "^beyla$"}, diff --git a/test/integration/k8s/daemonset/k8s_daemonset_z_metrics_test.go b/test/integration/k8s/daemonset/k8s_daemonset_z_metrics_test.go index f6d718f30..faa63d704 100644 --- a/test/integration/k8s/daemonset/k8s_daemonset_z_metrics_test.go +++ b/test/integration/k8s/daemonset/k8s_daemonset_z_metrics_test.go @@ -16,5 +16,6 @@ func TestProcessMetrics(t *testing.T) { "k8s_deployment_name": "^otherinstance$", "k8s_replicaset_name": "^otherinstance-.*", "k8s_pod_name": "^otherinstance-.*", + "k8s_owner_name": "^otherinstance$", })) }