Skip to content

pcp2openmetrics: add live timestamp mode#2637

Open
lmchilton wants to merge 1 commit into
performancecopilot:mainfrom
lmchilton:pcp2openmetrics-timestamps
Open

pcp2openmetrics: add live timestamp mode#2637
lmchilton wants to merge 1 commit into
performancecopilot:mainfrom
lmchilton:pcp2openmetrics-timestamps

Conversation

@lmchilton

Copy link
Copy Markdown
Contributor

update pcp2openmetrics tool to allow for live timestamp mode option. This update follows openmetric / prometheus exposing timestamp guidelines. Updated man page & QA #1131

Resolves issue #2538

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 9dcb3560-65b5-4d6d-a1e6-ec0f917fbb08

📥 Commits

Reviewing files that changed from the base of the PR and between 371f9c2 and bcc4cc6.

⛔ Files ignored due to path filters (1)
  • qa/1131.out is excluded by !**/*.out
📒 Files selected for processing (3)
  • qa/1131
  • src/pcp2openmetrics/pcp2openmetrics.1
  • src/pcp2openmetrics/pcp2openmetrics.py
✅ Files skipped from review due to trivial changes (1)
  • src/pcp2openmetrics/pcp2openmetrics.1
🚧 Files skipped from review as they are similar to previous changes (2)
  • qa/1131
  • src/pcp2openmetrics/pcp2openmetrics.py

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added live timestamp mode for pcp2openmetrics; when enabled, counter metrics now include corresponding <metric>_created samples during live runs.
    • Enhanced OpenMetrics output normalization to better handle label/instance placeholders and specific metric value substitutions.
  • Documentation
    • Documented the new --time-stamp / -l option in the pcp2openmetrics manpage.
  • Tests
    • Updated QA coverage to validate the new live timestamp behavior and the revised OpenMetrics normalization pipeline.

Walkthrough

pcp2openmetrics now accepts -l/--time-stamp and can emit _created metrics for live counter output. The manpage documents the option, and QA normalization plus an added test invocation were updated for the new output.

Changes

Live timestamp mode

Layer / File(s) Summary
CLI option and docs
src/pcp2openmetrics/pcp2openmetrics.py, src/pcp2openmetrics/pcp2openmetrics.1
Recognizes time_stamp, adds -l/--time-stamp, and documents live timestamp mode in the manpage.
Counter timestamp emission
src/pcp2openmetrics/pcp2openmetrics.py
Tracks first-seen timestamps for counter metrics and emits <metric>_created lines during live OpenMetrics output when timestamp mode is enabled.
QA normalization and test
qa/1131
Updates the OpenMetrics filter placeholders and adds a pcp2openmetrics -s2 --time-stamp kernel.pernode.cpu.idle test run.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Parser as pcp2openmetrics.py option parser
  participant Writer as PCP2OPENMETRICS.write_openmetrics()
  participant Output as OpenMetrics output
  User->>Parser: run with -l / --time-stamp
  Parser->>Writer: set self.time_stamp = 1
  Writer->>Output: emit counter metric value
  Writer->>Output: emit <metric>_created for live counters
Loading

Poem

I hopped through counters, brisk and keen,
and found a -l in the machine.
Now live outputs softly gleam,
with _created tags in the stream.
🐇

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding live timestamp mode to pcp2openmetrics.
Description check ✅ Passed The description matches the changeset by describing live timestamp mode, documentation, and QA updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pcp2openmetrics/pcp2openmetrics.1`:
- Around line 421-425: The SYNOPSIS short-option cluster is missing the newly
documented lowercase l option, so update the synopsis in pcp2openmetrics.1 to
match the documented command-line options. Keep the short-option list consistent
with the `-l, --time-stamp` entry by adding `l` in the compact options section
so users can discover it from the top-level usage summary.

In `@src/pcp2openmetrics/pcp2openmetrics.py`:
- Around line 142-146: The counter timestamp cache in pcp2openmetrics.py can
grow without bound because counter_timestamps only ever adds new (metric_name,
instance_id) keys. Update the live-mode counter handling paths around the
related metric processing code (including the sections near the referenced
counter-timestamp logic) to evict stale entries when instances disappear or are
no longer observed. Use the existing counter_timestamps structure as the cleanup
point so long-running exporter stability is preserved.
- Around line 58-59: The self.keys list in pcp2openmetrics.py has a missing
separator between the time_stamp and count_scale entries, causing those config
directives to merge into one invalid key. Update the list in the initialization
block where self.keys is defined so time_stamp and count_scale are separate
elements, preserving recognition of both directives.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: c37c1883-be10-4564-8af4-8c0dd5fd28c9

📥 Commits

Reviewing files that changed from the base of the PR and between 3d1a65d and 371f9c2.

⛔ Files ignored due to path filters (1)
  • qa/1131.out is excluded by !**/*.out
📒 Files selected for processing (3)
  • qa/1131
  • src/pcp2openmetrics/pcp2openmetrics.1
  • src/pcp2openmetrics/pcp2openmetrics.py

Comment thread src/pcp2openmetrics/pcp2openmetrics.1
Comment thread src/pcp2openmetrics/pcp2openmetrics.py Outdated
Comment on lines +142 to +146
# Counter metric timestamp tracking
# key - (metric_name, instance_id)
# value - timestamp when first seen
self.counter_timestamps = {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift

Prevent unbounded growth of counter_timestamps in long-running live mode.

self.counter_timestamps only adds keys and never removes stale (metric, inst) entries. With high instance churn, this can grow indefinitely and degrade long-lived exporter stability.

Also applies to: 509-513, 520-523

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pcp2openmetrics/pcp2openmetrics.py` around lines 142 - 146, The counter
timestamp cache in pcp2openmetrics.py can grow without bound because
counter_timestamps only ever adds new (metric_name, instance_id) keys. Update
the live-mode counter handling paths around the related metric processing code
(including the sections near the referenced counter-timestamp logic) to evict
stale entries when instances disappear or are no longer observed. Use the
existing counter_timestamps structure as the cleanup point so long-running
exporter stability is preserved.

update pcp2openmetrics tool to allow for live timestamp
mode option. This update follows openmetric / prometheus
exposing timestamp guidelines. Updated man page & QA performancecopilot#1131

Resolves upstream RFE issue [performancecopilot#2538]
@lmchilton lmchilton force-pushed the pcp2openmetrics-timestamps branch from 371f9c2 to bcc4cc6 Compare June 25, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant