Skip to content

Feat/kubeletstats psi metrics - #50948

Open
thisisvaishnav wants to merge 13 commits into
open-telemetry:mainfrom
thisisvaishnav:feat/kubeletstats-psi-metrics
Open

Feat/kubeletstats psi metrics#50948
thisisvaishnav wants to merge 13 commits into
open-telemetry:mainfrom
thisisvaishnav:feat/kubeletstats-psi-metrics

Conversation

@thisisvaishnav

Copy link
Copy Markdown

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

  • I, a human, wrote this pull request description myself.

…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)
…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)
@github-actions

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

  • Read our Contributing Guidelines.
  • Sign the CLA if you haven't already.
  • Follow the OpenTelemetry Generative AI policy: disclose any AI use in your contribution, and communicate (PR descriptions, review replies) in your own words rather than AI-generated text.
  • Give reviewers at least a few days before pinging them for feedback.
  • If you need help with general setup, development process, or contributor etiquette, ask in #opentelemetry-new-contributors.
  • First-time contributors should keep at most one PR marked as ready for review until their first PR is merged; once two are open for review, any further PR is automatically converted to draft.
  • If your change isn't one of our priority components, reviews may take more time.
  • Raise technical or Collector-specific questions in #otel-collector-dev or a Collector SIG meeting.

Comment thread .chloggen/kubeletstats-psi-metrics.yaml Outdated
Co-authored-by: Vibhanshu Singh <find.vibhanshu@gmail.com>
@singhvibhanshu

Copy link
Copy Markdown
Member

/workflow-approve

Comment thread .chloggen/kubeletstats-psi-metrics.yaml Outdated
thisisvaishnav and others added 2 commits September 13, 2026 18:44
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
@thisisvaishnav

Copy link
Copy Markdown
Author

@singhvibhanshu can you help me in solving the halt in the pr

@singhvibhanshu

Copy link
Copy Markdown
Member

/workflow-approve

thisisvaishnav and others added 3 commits September 13, 2026 19:38
- Replace assert.Equal(t, n, len(x)) with assert.Len(t, x, n)
- Replace assert.EqualValues with assert.Equal for int64 comparison
@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-09-13 22:44 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[receiver/kubeletstats] Expose PSI (Pressure Stall Information) metrics

2 participants