[k8s] Introduce semantic conventions for k8s Job labels and annotations (#2171)

Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
This commit is contained in:
odubajDT 2025-04-30 08:54:47 +02:00 committed by GitHub
parent d9b7765b7d
commit c0e7d69c09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 64 additions and 10 deletions

View File

@ -0,0 +1,22 @@
# Use this changelog template to create an entry for release notes.
#
# If your change doesn't affect end users you should instead start
# your pull request title with [chore] or use the "Skip Changelog" label.
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement
# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db)
component: k8s
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Introduce semantic conventions for k8s Job labels and annotations"
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
# The values here must be integers.
issues: [2137]
# (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:

View File

@ -27,16 +27,18 @@ Kubernetes resource attributes.
| <a id="k8s-deployment-uid" href="#k8s-deployment-uid">`k8s.deployment.uid`</a> | string | The UID of the Deployment. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-hpa-name" href="#k8s-hpa-name">`k8s.hpa.name`</a> | string | The name of the horizontal pod autoscaler. | `opentelemetry` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-hpa-uid" href="#k8s-hpa-uid">`k8s.hpa.uid`</a> | string | The UID of the horizontal pod autoscaler. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-job-annotation" href="#k8s-job-annotation">`k8s.job.annotation.<key>`</a> | string | The annotation key-value pairs placed on the Job. [4] | `k8s.job.annotation.number=1`; `k8s.job.annotation.data=` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-job-label" href="#k8s-job-label">`k8s.job.label.<key>`</a> | string | The label key-value pairs placed on the Job. [5] | `k8s.job.label.jobtype=ci`; `k8s.job.label.automated=` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-job-name" href="#k8s-job-name">`k8s.job.name`</a> | string | The name of the Job. | `opentelemetry` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-job-uid" href="#k8s-job-uid">`k8s.job.uid`</a> | string | The UID of the Job. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-namespace-name" href="#k8s-namespace-name">`k8s.namespace.name`</a> | string | The name of the namespace that the pod is running in. | `default` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-namespace-phase" href="#k8s-namespace-phase">`k8s.namespace.phase`</a> | string | The phase of the K8s namespace. [4] | `active`; `terminating` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-node-annotation" href="#k8s-node-annotation">`k8s.node.annotation.<key>`</a> | string | The annotation placed on the Node, the `<key>` being the annotation name, the value being the annotation value, even if the value is empty. [5] | `0`; `` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-node-label" href="#k8s-node-label">`k8s.node.label.<key>`</a> | string | The label placed on the Node, the `<key>` being the label name, the value being the label value, even if the value is empty. [6] | `arm64`; `` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-namespace-phase" href="#k8s-namespace-phase">`k8s.namespace.phase`</a> | string | The phase of the K8s namespace. [6] | `active`; `terminating` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-node-annotation" href="#k8s-node-annotation">`k8s.node.annotation.<key>`</a> | string | The annotation placed on the Node, the `<key>` being the annotation name, the value being the annotation value, even if the value is empty. [7] | `0`; `` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-node-label" href="#k8s-node-label">`k8s.node.label.<key>`</a> | string | The label placed on the Node, the `<key>` being the label name, the value being the label value, even if the value is empty. [8] | `arm64`; `` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-node-name" href="#k8s-node-name">`k8s.node.name`</a> | string | The name of the Node. | `node-1` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-node-uid" href="#k8s-node-uid">`k8s.node.uid`</a> | string | The UID of the Node. | `1eb3a0c6-0477-4080-a9cb-0cb7db65c6a2` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-pod-annotation" href="#k8s-pod-annotation">`k8s.pod.annotation.<key>`</a> | string | The annotation placed on the Pod, the `<key>` being the annotation name, the value being the annotation value. [7] | `true`; `x64`; `` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-pod-label" href="#k8s-pod-label">`k8s.pod.label.<key>`</a> | string | The label placed on the Pod, the `<key>` being the label name, the value being the label value. [8] | `my-app`; `x64`; `` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-pod-annotation" href="#k8s-pod-annotation">`k8s.pod.annotation.<key>`</a> | string | The annotation placed on the Pod, the `<key>` being the annotation name, the value being the annotation value. [9] | `true`; `x64`; `` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-pod-label" href="#k8s-pod-label">`k8s.pod.label.<key>`</a> | string | The label placed on the Pod, the `<key>` being the label name, the value being the label value. [10] | `my-app`; `x64`; `` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-pod-name" href="#k8s-pod-name">`k8s.pod.name`</a> | string | The name of the Pod. | `opentelemetry-pod-autoconf` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-pod-uid" href="#k8s-pod-uid">`k8s.pod.uid`</a> | string | The UID of the Pod. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-replicaset-name" href="#k8s-replicaset-name">`k8s.replicaset.name`</a> | string | The name of the ReplicaSet. | `opentelemetry` | ![Development](https://img.shields.io/badge/-development-blue) |
@ -87,24 +89,28 @@ conflict.
- A label `automated` with empty string value SHOULD be recorded as
the `k8s.cronjob.label.automated` attribute with value `""`.
**[4] `k8s.namespace.phase`:** This attribute aligns with the `phase` field of the
**[4] `k8s.job.annotation`:** The `<key>` being the annotation name, the value being the annotation value, even if the value is empty.
**[5] `k8s.job.label`:** The `<key>` being the label name, the value being the label value, even if the value is empty.
**[6] `k8s.namespace.phase`:** This attribute aligns with the `phase` field of the
[K8s NamespaceStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#namespacestatus-v1-core)
**[5] `k8s.node.annotation`:** Examples:
**[7] `k8s.node.annotation`:** Examples:
- An annotation `node.alpha.kubernetes.io/ttl` with value `0` SHOULD be recorded as
the `k8s.node.annotation.node.alpha.kubernetes.io/ttl` attribute with value `"0"`.
- An annotation `data` with empty string value SHOULD be recorded as
the `k8s.node.annotation.data` attribute with value `""`.
**[6] `k8s.node.label`:** Examples:
**[8] `k8s.node.label`:** Examples:
- A label `kubernetes.io/arch` with value `arm64` SHOULD be recorded
as the `k8s.node.label.kubernetes.io/arch` attribute with value `"arm64"`.
- A label `data` with empty string value SHOULD be recorded as
the `k8s.node.label.data` attribute with value `""`.
**[7] `k8s.pod.annotation`:** Examples:
**[9] `k8s.pod.annotation`:** Examples:
- An annotation `kubernetes.io/enforce-mountable-secrets` with value `true` SHOULD be recorded as
the `k8s.pod.annotation.kubernetes.io/enforce-mountable-secrets` attribute with value `"true"`.
@ -113,7 +119,7 @@ conflict.
- An annotation `data` with empty string value SHOULD be recorded as
the `k8s.pod.annotation.data` attribute with value `""`.
**[8] `k8s.pod.label`:** Examples:
**[10] `k8s.pod.label`:** Examples:
- A label `app` with value `my-app` SHOULD be recorded as
the `k8s.pod.label.app` attribute with value `"my-app"`.

View File

@ -353,6 +353,12 @@ successfully terminate.
|---|---|---|---|---|---|
| [`k8s.job.name`](/docs/attributes-registry/k8s.md) | string | The name of the Job. | `opentelemetry` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| [`k8s.job.uid`](/docs/attributes-registry/k8s.md) | string | The UID of the Job. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| [`k8s.job.annotation.<key>`](/docs/attributes-registry/k8s.md) | string | The annotation key-value pairs placed on the Job. [1] | `k8s.job.annotation.number=1`; `k8s.job.annotation.data=` | `Opt-In` | ![Development](https://img.shields.io/badge/-development-blue) |
| [`k8s.job.label.<key>`](/docs/attributes-registry/k8s.md) | string | The label key-value pairs placed on the Job. [2] | `k8s.job.label.jobtype=ci`; `k8s.job.label.automated=` | `Opt-In` | ![Development](https://img.shields.io/badge/-development-blue) |
**[1] `k8s.job.annotation`:** The `<key>` being the annotation name, the value being the annotation value, even if the value is empty.
**[2] `k8s.job.label`:** The `<key>` being the label name, the value being the label value, even if the value is empty.
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

View File

@ -245,6 +245,22 @@ groups:
brief: >
The name of the Job.
examples: ['opentelemetry']
- id: k8s.job.label
type: template[string]
stability: development
brief: >
The label key-value pairs placed on the Job.
note: |
The `<key>` being the label name, the value being the label value, even if the value is empty.
examples: ['k8s.job.label.jobtype=ci', 'k8s.job.label.automated=']
- id: k8s.job.annotation
type: template[string]
stability: development
brief: >
The annotation key-value pairs placed on the Job.
note: |
The `<key>` being the annotation name, the value being the annotation value, even if the value is empty.
examples: [ 'k8s.job.annotation.number=1', 'k8s.job.annotation.data=' ]
- id: k8s.cronjob.uid
type: string
stability: development

View File

@ -106,6 +106,10 @@ groups:
attributes:
- ref: k8s.job.uid
- ref: k8s.job.name
- ref: k8s.job.label
requirement_level: opt_in
- ref: k8s.job.annotation
requirement_level: opt_in
- id: resource.k8s.cronjob
type: resource