Skip to content

Commit 9b13449

Browse files
committed
Add k8s.namespace.phase metric and attribute
Signed-off-by: ChrsMark <[email protected]>
1 parent 373a695 commit 9b13449

File tree

5 files changed

+101
-0
lines changed

5 files changed

+101
-0
lines changed

.chloggen/add_k8s_ns_phase.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use this changelog template to create an entry for release notes.
2+
#
3+
# If your change doesn't affect end users you should instead start
4+
# your pull request title with [chore] or use the "Skip Changelog" label.
5+
6+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
7+
change_type: enhancement
8+
9+
# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db)
10+
component: k8s
11+
12+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
13+
note: Add k8s.namespace.phase metric along with the respective attribute
14+
15+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
16+
# The values here must be integers.
17+
issues: []
18+
19+
# (Optional) One or more lines of additional information to render under the primary note.
20+
# These lines will be padded with 2 spaces and then inserted directly into the document.
21+
# Use pipe (|) for multiline entries.
22+
subtext:

docs/attributes-registry/k8s.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Kubernetes resource attributes.
2929
| <a id="k8s-job-name" href="#k8s-job-name">`k8s.job.name`</a> | string | The name of the Job. | `opentelemetry` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
3030
| <a id="k8s-job-uid" href="#k8s-job-uid">`k8s.job.uid`</a> | string | The UID of the Job. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
3131
| <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` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
32+
| <a id="k8s-namespace-phase" href="#k8s-namespace-phase">`k8s.namespace.phase`</a> | string | The phase of the K8s namespace. [2] | `active`; `terminating` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
3233
| <a id="k8s-node-name" href="#k8s-node-name">`k8s.node.name`</a> | string | The name of the Node. | `node-1` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
3334
| <a id="k8s-node-uid" href="#k8s-node-uid">`k8s.node.uid`</a> | string | The UID of the Node. | `1eb3a0c6-0477-4080-a9cb-0cb7db65c6a2` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
3435
| <a id="k8s-pod-annotation" href="#k8s-pod-annotation">`k8s.pod.annotation.<key>`</a> | string | The annotation key-value pairs placed on the Pod, the `<key>` being the annotation name, the value being the annotation value. | `k8s.pod.annotation.kubernetes.io/enforce-mountable-secrets=true`; `k8s.pod.annotation.mycompany.io/arch=x64`; `k8s.pod.annotation.data=` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
@@ -65,6 +66,18 @@ Which states:
6566
Therefore, UIDs between clusters should be extremely unlikely to
6667
conflict.
6768

69+
**[2] `k8s.namespace.phase`:** This attribute aligns with the `phase` field of the
70+
[K8s NamespaceStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#namespacestatus-v1-core)
71+
72+
---
73+
74+
`k8s.namespace.phase` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
75+
76+
| Value | Description | Stability |
77+
|---|---|---|
78+
| `active` | A [persistentVolumeClaim](https://v1-29.docs.kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim) volume | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
79+
| `terminating` | A [configMap](https://v1-29.docs.kubernetes.io/docs/concepts/storage/volumes/#configmap) volume | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
80+
6881
---
6982

7083
`k8s.volume.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

docs/system/k8s-metrics.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,5 +329,41 @@ This metric is [recommended][MetricRecommended].
329329
<!-- END AUTOGENERATED TEXT -->
330330
<!-- endsemconv -->
331331

332+
### Metric: `k8s.namespace.phase`
333+
334+
This metric is [recommended][MetricRecommended].
335+
336+
<!-- semconv metric.k8s.namespace.phase -->
337+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
338+
<!-- see templates/registry/markdown/snippet.md.j2 -->
339+
<!-- prettier-ignore-start -->
340+
<!-- markdownlint-capture -->
341+
<!-- markdownlint-disable -->
342+
343+
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
344+
| -------- | --------------- | ----------- | -------------- | --------- |
345+
| `k8s.namespace.phase` | UpDownCounter | `1` | Operational status: `1` (true) or `0` (false) for each of the possible phases | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
346+
347+
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
348+
|---|---|---|---|---|---|
349+
| [`k8s.namespace.phase`](/docs/attributes-registry/k8s.md) | string | The phase of the K8s namespace. [1] | `active`; `terminating` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
350+
351+
**[1] `k8s.namespace.phase`:** This attribute aligns with the `phase` field of the
352+
[K8s NamespaceStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#namespacestatus-v1-core)
353+
354+
---
355+
356+
`k8s.namespace.phase` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
357+
358+
| Value | Description | Stability |
359+
|---|---|---|
360+
| `active` | A [persistentVolumeClaim](https://v1-29.docs.kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim) volume | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
361+
| `terminating` | A [configMap](https://v1-29.docs.kubernetes.io/docs/concepts/storage/volumes/#configmap) volume | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
362+
363+
<!-- markdownlint-restore -->
364+
<!-- prettier-ignore-end -->
365+
<!-- END AUTOGENERATED TEXT -->
366+
<!-- endsemconv -->
367+
332368
[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status
333369
[MetricRecommended]: /docs/general/metric-requirement-level.md#recommended

model/k8s/metrics.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,15 @@ groups:
126126
attributes:
127127
- ref: network.interface.name
128128
- ref: network.io.direction
129+
130+
# k8s.namespace.* metrics
131+
- id: metric.k8s.namespace.phase
132+
type: metric
133+
metric_name: k8s.namespace.phase
134+
stability: experimental
135+
brief: "Operational status: `1` (true) or `0` (false) for each of the possible phases"
136+
instrument: updowncounter
137+
unit: "1"
138+
attributes:
139+
- ref: k8s.namespace.phase
140+
requirement_level: required

model/k8s/registry.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,21 @@ groups:
214214
value: 'local'
215215
brief: "A [local](https://v1-29.docs.kubernetes.io/docs/concepts/storage/volumes/#local) volume"
216216
stability: experimental
217+
- id: k8s.namespace.phase
218+
stability: experimental
219+
brief: >
220+
The phase of the K8s namespace.
221+
note: |
222+
This attribute aligns with the `phase` field of the
223+
[K8s NamespaceStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#namespacestatus-v1-core)
224+
examples: [ "active", "terminating" ]
225+
type:
226+
members:
227+
- id: active
228+
value: 'active'
229+
brief: "A [persistentVolumeClaim](https://v1-29.docs.kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim) volume"
230+
stability: experimental
231+
- id: terminating
232+
value: 'terminating'
233+
brief: "A [configMap](https://v1-29.docs.kubernetes.io/docs/concepts/storage/volumes/#configmap) volume"
234+
stability: experimental

0 commit comments

Comments
 (0)