Add process.paging.faults and process.uptime runtime metrics#653
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ 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 Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
…riggered in between callbacks
851be40 to
fbaae9b
Compare
| 'Cumulative time spent freeing memory during GC', | ||
| ); | ||
| $processUptime = $meter->createObservableGauge( | ||
| 'process.uptime', |
There was a problem hiding this comment.
| 'process.uptime', | |
| 'php.uptime', |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.faultsobservable counter (minor/major faults) sourced fromgetrusage(). - Add
process.uptimeobservable gauge (PHP 8.3+) sourced from GC timing status and refactor GC registration to a singlebatchObserve. - 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.
| 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+** | |
Adds additional recommended process metrics:
process.paging.faultsprocess.uptimeFollow-up to #645, cc @intuibase