From d0c01a5763524a2785c84ca2e194eac622df2ad0 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 8 Jun 2022 20:05:31 -0700 Subject: [PATCH] [receiver/kubeletstats] Bring back k8s.container.name attribute `k8s.container.name` attribute was recently unintentionally changed to `container.name`. This change brings `k8s.container.name` back --- CHANGELOG.md | 2 ++ receiver/kubeletstatsreceiver/documentation.md | 2 +- .../internal/kubelet/resource.go | 2 +- .../internal/metadata/generated_metrics_v2.go | 14 +++++++------- receiver/kubeletstatsreceiver/metadata.yaml | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dac8a50e3da..f4c3370b30ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ ### 🧰 Bug fixes 🧰 +- `kubletetstatsreceiver`: Bring back `k8s.container.name` attribute (#10848) + ## v0.53.0 ### 🛑 Breaking changes 🛑 diff --git a/receiver/kubeletstatsreceiver/documentation.md b/receiver/kubeletstatsreceiver/documentation.md index d77f4d9a04ed..ad116f508bcb 100644 --- a/receiver/kubeletstatsreceiver/documentation.md +++ b/receiver/kubeletstatsreceiver/documentation.md @@ -66,11 +66,11 @@ metrics: | ---- | ----------- | ---- | | aws.volume.id | The id of the AWS Volume | String | | container.id | Container id used to identify container | String | -| container.name | Container name used by container runtime | String | | fs.type | The filesystem type of the Volume | String | | gce.pd.name | The name of the persistent disk in GCE | String | | glusterfs.endpoints.name | The endpoint name that details Glusterfs topology | String | | glusterfs.path | Glusterfs volume path | String | +| k8s.container.name | Container name used by container runtime | String | | k8s.namespace.name | The name of the namespace that the pod is running in | String | | k8s.node.name | The name of the Node | String | | k8s.persistentvolumeclaim.name | The name of the Persistent Volume Claim | String | diff --git a/receiver/kubeletstatsreceiver/internal/kubelet/resource.go b/receiver/kubeletstatsreceiver/internal/kubelet/resource.go index 5dcc152b9fec..20a65261c93f 100644 --- a/receiver/kubeletstatsreceiver/internal/kubelet/resource.go +++ b/receiver/kubeletstatsreceiver/internal/kubelet/resource.go @@ -29,7 +29,7 @@ func getContainerResourceOptions(sPod stats.PodStats, sContainer stats.Container metadata.WithK8sPodUID(sPod.PodRef.UID), metadata.WithK8sPodName(sPod.PodRef.Name), metadata.WithK8sNamespaceName(sPod.PodRef.Namespace), - metadata.WithContainerName(sContainer.Name), + metadata.WithK8sContainerName(sContainer.Name), } extraResources, err := k8sMetadata.getExtraResources(sPod.PodRef, MetadataLabelContainerID, sContainer.Name) diff --git a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_v2.go b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_v2.go index 0ecfa1e14975..05321b111d04 100644 --- a/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_v2.go +++ b/receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_v2.go @@ -2445,13 +2445,6 @@ func WithContainerID(val string) ResourceMetricsOption { } } -// WithContainerName sets provided value as "container.name" attribute for current resource. -func WithContainerName(val string) ResourceMetricsOption { - return func(rm pmetric.ResourceMetrics) { - rm.Resource().Attributes().UpsertString("container.name", val) - } -} - // WithFsType sets provided value as "fs.type" attribute for current resource. func WithFsType(val string) ResourceMetricsOption { return func(rm pmetric.ResourceMetrics) { @@ -2480,6 +2473,13 @@ func WithGlusterfsPath(val string) ResourceMetricsOption { } } +// WithK8sContainerName sets provided value as "k8s.container.name" attribute for current resource. +func WithK8sContainerName(val string) ResourceMetricsOption { + return func(rm pmetric.ResourceMetrics) { + rm.Resource().Attributes().UpsertString("k8s.container.name", val) + } +} + // WithK8sNamespaceName sets provided value as "k8s.namespace.name" attribute for current resource. func WithK8sNamespaceName(val string) ResourceMetricsOption { return func(rm pmetric.ResourceMetrics) { diff --git a/receiver/kubeletstatsreceiver/metadata.yaml b/receiver/kubeletstatsreceiver/metadata.yaml index ec66084aacf3..88d69aaa7e5b 100644 --- a/receiver/kubeletstatsreceiver/metadata.yaml +++ b/receiver/kubeletstatsreceiver/metadata.yaml @@ -13,7 +13,7 @@ resource_attributes: k8s.namespace.name: description: "The name of the namespace that the pod is running in" type: string - container.name: + k8s.container.name: description: "Container name used by container runtime" type: string container.id: