Skip to content

Add process.paging.faults and process.uptime runtime metrics#653

Open
Nevay wants to merge 5 commits into
open-telemetry:mainfrom
Nevay:feature/additional-runtime-metrics
Open

Add process.paging.faults and process.uptime runtime metrics#653
Nevay wants to merge 5 commits into
open-telemetry:mainfrom
Nevay:feature/additional-runtime-metrics

Conversation

@Nevay

@Nevay Nevay commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Adds additional recommended process metrics:

Follow-up to #645, cc @intuibase

@Nevay
Nevay requested a review from a team as a code owner July 8, 2026 20:04
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.56098% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.22%. Comparing base (370a207) to head (4cc9d16).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...c/Metrics/Runtime/src/GarbageCollectionMetrics.php 96.77% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #653      +/-   ##
============================================
+ Coverage     81.14%   81.22%   +0.07%     
- Complexity     1478     1483       +5     
============================================
  Files           103      103              
  Lines          5586     5604      +18     
============================================
+ Hits           4533     4552      +19     
+ Misses         1053     1052       -1     
Flag Coverage Δ
Context/Swoole 0.00% <ø> (ø)
Exporter/Instana 49.80% <ø> (ø)
Instrumentation/AwsSdk 82.14% <ø> (ø)
Instrumentation/CakePHP 20.42% <ø> (ø)
Instrumentation/CodeIgniter 79.31% <ø> (ø)
Instrumentation/Curl 86.88% <ø> (ø)
Instrumentation/Doctrine 92.82% <ø> (ø)
Instrumentation/ExtAmqp 88.80% <ø> (ø)
Instrumentation/Guzzle 79.76% <ø> (+3.51%) ⬆️
Instrumentation/HttpAsyncClient 78.94% <ø> (ø)
Instrumentation/HttpConfig 28.76% <ø> (ø)
Instrumentation/IO 0.00% <ø> (ø)
Instrumentation/Magento2 88.12% <ø> (ø)
Instrumentation/MongoDB 76.84% <ø> (ø)
Instrumentation/OpenAIPHP 86.71% <ø> (ø)
Instrumentation/PostgreSql 91.36% <ø> (ø)
Instrumentation/Psr14 77.41% <ø> (ø)
Instrumentation/Psr15 89.74% <ø> (ø)
Instrumentation/Psr16 97.43% <ø> (ø)
Instrumentation/Psr18 79.41% <ø> (ø)
Instrumentation/Psr6 97.56% <ø> (ø)
Instrumentation/ReactPHP 99.41% <ø> (ø)
Instrumentation/Session 94.28% <ø> (ø)
Instrumentation/Slim 84.21% <ø> (ø)
Metrics/Runtime 90.66% <97.56%> (+0.12%) ⬆️
Propagation/CloudTrace 90.69% <ø> (ø)
Propagation/Instana 98.07% <ø> (ø)
Propagation/ServerTiming 94.73% <ø> (ø)
Propagation/TraceResponse 94.73% <ø> (ø)
ResourceDetectors/Azure 91.66% <ø> (ø)
ResourceDetectors/DigitalOcean 100.00% <ø> (ø)
Sampler/Xray 78.38% <ø> (ø)
Shims/OpenTracing 92.99% <ø> (ø)
SqlCommenter 95.58% <ø> (ø)
Utils/Test 87.79% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/Metrics/Runtime/src/CpuMetrics.php 100.00% <100.00%> (ø)
...c/Metrics/Runtime/src/GarbageCollectionMetrics.php 98.46% <96.77%> (-1.54%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 370a207...4cc9d16. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Nevay
Nevay force-pushed the feature/additional-runtime-metrics branch from 851be40 to fbaae9b Compare July 8, 2026 20:12
'Cumulative time spent freeing memory during GC',
);
$processUptime = $meter->createObservableGauge(
'process.uptime',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
'process.uptime',
'php.uptime',

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.

I'm not sure what the specification suggests here, but uptime seems to be more process-related than technology-related.

Do you think it might be useful to keep it for the FPM and Apache SAPIs as well, so that we can collect metrics on worker lifetime?

If you decide to go with php.uptime, don't forget to update it in README.md.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds two additional OpenTelemetry recommended process runtime metrics to the PHP runtime metrics contrib package: paging faults (process.paging.faults) and process uptime (process.uptime), with corresponding implementation, tests, and documentation updates.

Changes:

  • Add process.paging.faults observable counter (minor/major faults) sourced from getrusage().
  • Add process.uptime observable gauge (PHP 8.3+) sourced from GC timing status and refactor GC registration to a single batchObserve.
  • Update unit tests and README metric tables to reflect the new instruments.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Metrics/Runtime/src/CpuMetrics.php Adds process.paging.faults metric and emits minor/major fault observations.
src/Metrics/Runtime/tests/Unit/CpuMetricsTest.php Updates expectations for the new counter and adds paging-fault observation coverage.
src/Metrics/Runtime/src/GarbageCollectionMetrics.php Adds process.uptime and folds PHP 8.3 timing metrics into the main GC observer callback.
src/Metrics/Runtime/tests/Unit/GarbageCollectionMetricsTest.php Updates instrument-count expectations and callback arity for the refactored GC observer.
src/Metrics/Runtime/README.md Documents process.uptime and process.paging.faults in the metrics tables.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +91 to +94
if (PHP_SAPI === 'cli') {
// @phan-suppress-next-line PhanTypeInvalidDimOffset, PhanTypeMismatchArgument -- fields added in PHP 8.3
$uptimeObs->observe($status['application_time']);
}
| `php.gc.collector_time` | Counter | `s` | Cumulative time spent in the GC collector. **PHP 8.3+** |
| `php.gc.destructor_time` | Counter | `s` | Cumulative time spent running destructors during GC. **PHP 8.3+** |
| `php.gc.free_time` | Counter | `s` | Cumulative time spent freeing memory during GC. **PHP 8.3+** |
| `process.uptime` | Gauge | `s` | The time the process has been running. **PHP 8.3+** |
Comment thread src/Metrics/Runtime/README.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

3 participants