Repository: open-telemetry/opentelemetry-collector-contrib (Go)

Issue:
[receiver/k8scluster] No longer adding container state metadata on container.id
### Component(s)

receiver/k8scluster

### What happened?

## Description
Starting in v0.80.0 and above, the `k8scluster` receiver is no longer capturing and sending container state metadata against the resource id `container.id`

## Steps to Reproduce
Run the latest version of the collector with `k8scluster` receiver

## Expected Result
Container metadata, example `container.status:running` should be displayed added on the `container.id` attribute

## Actual Result
`container.status:running` is missing

### Collector version

v0.80.0 and above

### Additional context

A fix has been identified and shortly it will be linked to this issue


Discussion:
Pinging code owners:
- receiver/k8scluster: @dmitryax @TylerHelmuth @povilasv

%s See [Adding Labels via Comments](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#adding-labels-via-comments) if you do not have permissions to add labels yourself.




Patch:
diff --git a/.chloggen/containermeta.yaml b/.chloggen/containermeta.yaml
new file mode 100644
index 0000000000000..76387cde3bdd0
--- /dev/null
+++ b/.chloggen/containermeta.yaml
@@ -0,0 +1,27 @@
+# Use this changelog template to create an entry for release notes.
+
+# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
+change_type: bug_fix
+
+# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
+component: k8sclusterreceiver
+
+# A brief description of the change.  Surround your text with quotes ("") if it needs to start with a backtick (`).
+note: Fix container state metadata
+
+# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
+issues: [32676]
+
+# (Optional) One or more lines of additional information to render under the primary note.
+# These lines will be padded with 2 spaces and then inserted directly into the document.
+# Use pipe (|) for multiline entries.
+subtext:
+
+# If your change doesn't affect end users or the exported elements of any package,
+# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
+# Optional: The change log or logs in which this entry should be included.
+# e.g. '[user]' or '[user, api]'
+# Include 'user' if the change is relevant to end users.
+# Include 'api' if there is a change to a library API.
+# Default: '[user]'
+change_logs: []
diff --git a/receiver/k8sclusterreceiver/internal/pod/pods.go b/receiver/k8sclusterreceiver/internal/pod/pods.go
index 14e98071e1ec6..ed0d0e2534880 100644
--- a/receiver/k8sclusterreceiver/internal/pod/pods.go
+++ b/receiver/k8sclusterreceiver/internal/pod/pods.go
@@ -55,6 +55,7 @@ func Transform(pod *corev1.Pod) *corev1.Pod {
 			ContainerID:          cs.ContainerID,
 			RestartCount:         cs.RestartCount,
 			Ready:                cs.Ready,
+			State:                cs.State,
 			LastTerminationState: cs.LastTerminationState,
 		})
 	}


Test patch:
diff --git a/receiver/k8sclusterreceiver/internal/pod/pods_test.go b/receiver/k8sclusterreceiver/internal/pod/pods_test.go
index b82f66bfbeaa2..aee1aa9dfb3a1 100644
--- a/receiver/k8sclusterreceiver/internal/pod/pods_test.go
+++ b/receiver/k8sclusterreceiver/internal/pod/pods_test.go
@@ -348,6 +348,7 @@ func podWithOwnerReference(kind string) *corev1.Pod {
 }
 
 func TestTransform(t *testing.T) {
+	containerState := corev1.ContainerState{Running: &corev1.ContainerStateRunning{StartedAt: v1.Now()}}
 	originalPod := &corev1.Pod{
 		ObjectMeta: v1.ObjectMeta{
 			Name:      "my-pod",
@@ -429,7 +430,7 @@ func TestTransform(t *testing.T) {
 					ContainerID:  "abc12345",
 					RestartCount: 2,
 					Ready:        true,
-					State:        corev1.ContainerState{Running: &corev1.ContainerStateRunning{StartedAt: v1.Now()}},
+					State:        containerState,
 				},
 			},
 		},
@@ -470,6 +471,7 @@ func TestTransform(t *testing.T) {
 					ContainerID:  "abc12345",
 					RestartCount: 2,
 					Ready:        true,
+					State:        containerState,
 				},
 			},
 		},