Feat/kubeletstats psi metrics - #50948
Open
thisisvaishnav wants to merge 13 commits into
Open
Conversation
…tainer
Add 18 new opt-in metrics (all enabled: false) exposing Linux PSI
(Pressure Stall Information) data from the kubelet /stats/summary
endpoint for CPU, memory, and IO pressure across node, pod, and
container scopes.
New metrics:
- k8s.node.{cpu,memory,io}.pressure.{avg,total}
- k8s.pod.{cpu,memory,io}.pressure.{avg,total}
- container.{cpu,memory,io}.pressure.{avg,total}
The .avg metrics carry pressure.type (some|full) and pressure.window
(10s|60s|300s) attributes. The .total metrics carry pressure.type only.
Unit for .total is nanoseconds (ns), matching PSIData.Total in the
kubelet API. Requires Linux >= 4.20 with cgroup v2 and CONFIG_PSI=y;
nil PSI pointers on cgroup v1 or Windows nodes are handled safely.
Fixes open-telemetry#50943
Assisted-by: Antigravity (Google DeepMind)
…fault coverage for PSI metrics - Six thin tests (Memory/IO for Node/Pod/Container) now assert data-point count and concrete int64 values for both 'some' and 'full' pressure types - Add TestPSIIONilPSIField covering the distinct path where IOStats exists but PSI is nil - Expand TestPSIDisabledByDefault to cover all 9 scope×resource pairs (node/pod/container × CPU/memory/IO) ensuring the full opt-in contract is verified - Remove misleading 'avoids import cycle with zap' comment from newTestLogger Assisted-by: Antigravity (Google DeepMind)
- psi.go: fix gosec G115 nolint comment — clarify overflow requires 292+ years of cumulative stall and that kernel counters reset on reboot (not a sign issue) - psi.go: replace heap-allocating slice literal with fixed-size [2]struct array - accumulator.go: annotate system-containers TODO with #ISSUE placeholder so it is traceable; includes note to open a GitHub issue before submitting - metadata/psi.go: add one-liner godoc to all 9 exported PSIMetrics vars - .chloggen/kubeletstats-psi-metrics.yaml: add changelog entry (chloggen validate gate) Assisted-by: Antigravity (Google DeepMind)
…gate for addIOPSIMetrics removal)
…rn at all 3 call sites Council verdict: the wrapper was a 4-line trampoline with no unique semantics. IOStats.PSI is structurally identical to CPUStats.PSI and MemoryStats.PSI. Inlining restores call-site symmetry across node/pod/container accumulators and keeps psi.go scoped to PSI primitives only. Assisted-by: Antigravity (Google DeepMind)
thisisvaishnav
requested review from
a team,
ChrsMark,
TylerHelmuth and
dmitryax
as code owners
September 13, 2026 11:16
Contributor
|
Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib. Important reminders:
|
Co-authored-by: Vibhanshu Singh <find.vibhanshu@gmail.com>
Member
|
/workflow-approve |
Co-authored-by: Vibhanshu Singh <find.vibhanshu@gmail.com>
…receiver PSI code - Remove tautological nil guard (non-nil != nil) in TestAddPSIMetricsWithIOStatsPSI - Replace impossible nil guard (nil != nil) in TestAddPSIMetricsNilIOStatsPSI with a direct call to addPSIMetrics(nil) to test the function's own nil-safety - Remove unused //nolint:gosec directive on int64(entry.data.Total) conversion
Author
|
@singhvibhanshu can you help me in solving the halt in the pr |
Member
|
/workflow-approve |
- Replace assert.Equal(t, n, len(x)) with assert.Len(t, x, n) - Replace assert.EqualValues with assert.Equal for int64 comparison
Pull request dashboard statusWaiting on reviewers · refreshed 2026-09-13 22:44 UTC Review the latest changes. Status above doesn't look right?
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds PSI (Pressure Stall Information) metrics support to the kubeletstatsreceiver. PSI data has been available in the kubelet Summary API since it GA'd in Kubernetes v1.36, but the receiver was not reading or exposing it.
This PR adds 18 new metrics across the node, pod, and container scopes, covering CPU, memory, and I/O pressure. All 18 metrics are disabled by default (opt-in) to avoid unexpected cardinality/scrape overhead for users who don't need them.
PSI requires Linux kernel ≥ 4.20 with cgroup v2 enabled. On nodes running cgroup v1 or Windows, the relevant PSI fields are nil, and the receiver handles this safely without erroring or emitting partial/incorrect data.
Link to tracking issue
Fixes #50943
Testing
go test ./... passes across all 3 packages in kubeletstatsreceiver.
Added 17 unit tests in psi_test.go covering:
All 9 scope × resource combinations (node/pod/container × cpu/memory/io)
s.IO == nil handling
s.CPU == nil handling
IOStats.PSI == nil handling
All 18 metrics being disabled by default
Correctness of emitted metric values
Completeness of pressure.type and pressure.window attributes
Documentation
metadata.yaml updated to define the 18 new PSI metrics.
documentation.md regenerated via make generate, reflecting the new metrics along with their descriptions, attributes, and types.
Authorship