Skip to content

Commit c2a5972

Browse files
povilasvJaredTan95
authored andcommitted
[k8sclusterreceiver] add k8s.pod.qos_class optional resource attribute (open-telemetry#27485)
**Description:** <Describe what has changed.> add k8s.pod.qos_class optional resource attriute **Link to tracking Issue:** <Issue number if applicable> open-telemetry#27483 **Testing:** <Describe what testing was performed and which tests were added.> - updated unit tests **Documentation:** <Describe the documentation added.> - generated
1 parent 99f3758 commit c2a5972

File tree

13 files changed

+70
-4
lines changed

13 files changed

+70
-4
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: k8sclusterreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "add optional k8s.pod.qos_class resource attribute"
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [27483]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

receiver/k8sclusterreceiver/documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ Current status reason of the pod (1 - Evicted, 2 - NodeAffinity, 3 - NodeLost, 4
429429
| k8s.node.name | The k8s node name. | Any Str | true |
430430
| k8s.node.uid | The k8s node uid. | Any Str | true |
431431
| k8s.pod.name | The k8s pod name. | Any Str | true |
432+
| k8s.pod.qos_class | The k8s pod qos class name. One of Guaranteed, Burstable, BestEffort. | Any Str | false |
432433
| k8s.pod.uid | The k8s pod uid. | Any Str | true |
433434
| k8s.replicaset.name | The k8s replicaset name | Any Str | true |
434435
| k8s.replicaset.uid | The k8s replicaset uid | Any Str | true |

receiver/k8sclusterreceiver/internal/metadata/generated_config.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/k8sclusterreceiver/internal/metadata/generated_config_test.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/k8sclusterreceiver/internal/metadata/generated_metrics_test.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/k8sclusterreceiver/internal/metadata/generated_resource.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/k8sclusterreceiver/internal/metadata/generated_resource_test.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/k8sclusterreceiver/internal/metadata/testdata/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ all_set:
130130
enabled: true
131131
k8s.pod.name:
132132
enabled: true
133+
k8s.pod.qos_class:
134+
enabled: true
133135
k8s.pod.uid:
134136
enabled: true
135137
k8s.replicaset.name:
@@ -283,6 +285,8 @@ none_set:
283285
enabled: false
284286
k8s.pod.name:
285287
enabled: false
288+
k8s.pod.qos_class:
289+
enabled: false
286290
k8s.pod.uid:
287291
enabled: false
288292
k8s.replicaset.name:

receiver/k8sclusterreceiver/internal/pod/pods.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ func Transform(pod *corev1.Pod) *corev1.Pod {
4141
NodeName: pod.Spec.NodeName,
4242
},
4343
Status: corev1.PodStatus{
44-
Phase: pod.Status.Phase,
44+
Phase: pod.Status.Phase,
45+
QOSClass: pod.Status.QOSClass,
4546
},
4647
}
4748
for _, cs := range pod.Status.ContainerStatuses {
@@ -76,6 +77,7 @@ func RecordMetrics(logger *zap.Logger, mb *metadata.MetricsBuilder, pod *corev1.
7677
rb.SetK8sNodeName(pod.Spec.NodeName)
7778
rb.SetK8sPodName(pod.Name)
7879
rb.SetK8sPodUID(string(pod.UID))
80+
rb.SetK8sPodQosClass(string(pod.Status.QOSClass))
7981
mb.EmitForResource(metadata.WithResource(rb.Emit()))
8082

8183
for _, c := range pod.Spec.Containers {

receiver/k8sclusterreceiver/internal/pod/pods_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func TestPodStatusReasonAndContainerMetricsReportCPUMetrics(t *testing.T) {
6868

6969
mbc := metadata.DefaultMetricsBuilderConfig()
7070
mbc.Metrics.K8sPodStatusReason.Enabled = true
71+
mbc.ResourceAttributes.K8sPodQosClass.Enabled = true
7172
ts := pcommon.Timestamp(time.Now().UnixNano())
7273
mb := metadata.NewMetricsBuilder(mbc, receivertest.NewNopCreateSettings())
7374
RecordMetrics(zap.NewNop(), mb, pod, ts)

0 commit comments

Comments
 (0)