102 Commits

Author SHA1 Message Date
Ronit Sabhaya 14a2654e33 Refactor readFull() to use iterative while loop instead of recursion (#119)
there was a recursion which was unbounded changed it to iterative while
loop
1.2.2
2026-05-13 14:36:29 +01:00
Ronit Sabhaya 2a3b591f22 Add process page fault metrics (minor/major) using getrusage on Linux and Darwin (#118)
Add process page fault metrics (minor/major) using getrusage on Linux
and Darwin

### Motivation:

Identifying memory pressure and unexpected latency caused by disk I/O is
critical for performance monitoring. Major page faults (which require
disk I/O) are a common cause of unexpected latency in applications.
Adding minor and major page fault metrics allows developers to monitor
these events, providing better visibility into memory access patterns
and application performance.

### Modifications:

- Updated `SystemMetricsMonitor+Linux.swift` to extract `ru_minflt`
(minor faults) and `ru_majflt` (major faults) from the existing
`getrusage(RUSAGE_SELF)` call.
- Updated `SystemMetricsMonitor+Darwin.swift` to include a new
`getrusage(RUSAGE_SELF)` call to extract `ru_minflt` and `ru_majflt`.
- Added `minorPageFaults` and `majorPageFaults` fields to the
`SystemMetricsMonitor.Data` structure.
- Created `process_page_faults_minor_total` and
`process_page_faults_major_total` as default labels in
`SystemMetricsMonitorConfiguration`.
- Updated test suites across both platforms to validate the new metrics
with dedicated cross-check tests.

### Result:

The system metrics monitor now automatically collects and exports two
new gauges (`process_page_faults_minor_total` and
`process_page_faults_major_total`), providing immediate visibility into
process-level memory page faults without requiring any configuration
changes for existing users.

Thanks @Renish-patel for helping and guidance

---------

Co-authored-by: Arumit Kumar <arumitkumar2004@gmail.com>
Co-authored-by: Renish Patel <renishpatel2482001@gmail.com>
Co-authored-by: Vladimir Kukushkin <kukushechkin@mac.com>
2026-05-11 15:35:08 +02:00
Ronit Sabhaya f71ac8c844 Replace force unwraps with try #require in Linux data provider tests (#117)
Refactor force unwraps to use `try #require` in Linux data provider
tests

### Motivation:

While looking through the test suites, I noticed that
`LinuxDataProviderTests.swift` was still using a pattern of doing an
`#expect(value != nil)` check followed by a force unwrap (`value!`). In
the new Swift Testing framework, the idiomatic and safer way to handle
optionals is by using `try #require()`. Force unwrapping risks crashing
the entire test runner with a fatal error, whereas `#require` gracefully
fails the individual test and provides a clear diagnostic message.

### Modifications:

- Replaced all `#expect(value != nil)` assertions and subsequent force
unwraps with `try #require(value)` in `LinuxDataProviderTests.swift`.
- Cleaned up the local variable assignments to be more concise.

### Result:

The Linux test suite is now safer, won't crash the test runner on
failure, and the code style is consistent with the
`DarwinDataProviderTests.swift` suite.

Thanks for letting me know about this during our review @brandongrubio
:)

Co-authored-by: Brandon Grubio <brandongrubio@gmail.com>
2026-05-07 13:28:18 +00:00
Ronit Sabhaya 60beb5f0ff Fix process_max_fds to use soft limit (rlim_cur) on Linux (#116)
Fix `process_max_fds` on Linux to report the soft limit instead of the
hard limit.

### Motivation:

While looking at how the monitor works across different platforms, we
noticed an inconsistency in how the maximum file descriptors metric
(`process_max_fds`) is reported. On Darwin, the monitor correctly
fetches the soft limit (`rlim_cur`), which is the actual ceiling the
process will hit before things start failing. However, on Linux, it was
pulling the hard limit (`rlim_max`). This is pretty misleading because
the hard limit on Linux is often set super high or even unlimited, which
doesn't reflect the actual enforced limit for the application. The
Prometheus convention is also to report the soft limit for this metric.

### Modifications:

- Swapped out `_rlim.rlim_max` for `_rlim.rlim_cur` in
`SystemMetricsMonitor+Linux.swift` so it pulls the soft limit.
- Added cross-check tests for both Linux and Darwin to verify that
`maxFileDescriptors` actually matches the system's `rlim_cur`.

### Result:

The `process_max_fds` metric on Linux will now accurately report the
soft limit, making it consistent with the Darwin implementation and
standard Prometheus guidelines. You'll now see the actual number of
files your process is allowed to open, rather than a theoretical
ceiling.


Thanks to @Renish-patel for helping me writing tests

Co-authored-by: Renish-patel <renishpatel2482001@gmail.com>
2026-05-05 16:32:56 +01:00
Ronit Sabhaya a30ccdbfea Fix integer truncation in process start time to preserve sub-second precision (#115)
Fix integer truncation in process start time to preserve sub-second
precision

### Motivation:

This PR fixes a bug where the `process_start_time_seconds` metric was
being calculated using integer division, causing the sub-second
fractional component of the start time to be silently truncated. This
resulted in the reported metric being inaccurate by up to ~1 second.

### Modifications:

- Updated the `SystemMetricsMonitor.Data` struct to store
`startTimeSeconds` as a `Double` instead of an `Int` to preserve
fractional seconds.
- Linux: Converted `startTimeTicks` and `clockTicksPerSecond` to
`Double` prior to division in `SystemMetricsMonitor+Linux.swift` to
prevent integer truncation.
- Darwin: Included the `pbi_start_tvusec` (microseconds) field from
`kinfo_proc` to properly calculate the fractional component in
`SystemMetricsMonitor+Darwin.swift`.
- Updated `DarwinDataProviderTests` to compare the `Double` start time
metric against the full sub-second timestamp provided by `sysctl`.

### Result:

This aligns the process start time precision with how CPU time is
currently computed and with Prometheus metric conventions.
2026-05-05 05:17:28 -07:00
Vladimir Kukushkin 01347728f0 Cleanup repository structure (#113)
Unify repos layout across the ecosystem:

1. Remove `CONTRIBUTORS.md` and mentions of it.
2. Remove `CODE_OF_CONDUCT.md` and mentions of it.
3. From `CONTRIBUTING.md` remove "Writing a Patch" and "Commit Message
Template" sections.
4. Remove `.mailmap` and mentions of it.
5. Remove `dev/git.commit.template` and mentions of it.
6. Remove `SECURITY.md`, if it is referenced somewhere, change it to
reference to the org security file
"https://github.com/apple/swift-log?tab=security-ov-file".
7. Remove copyright header from `Package.swift` and version-specific
package manifests.
8. Add SPI shields to the `README.md`.
9. Add "How to contribute your work" section in `CONTRIBUTING.md`.
10. Add "Add Automated release process" section in `CONTRIBUTING.md`.
2026-04-28 14:37:50 +00:00
Ronit Sabhaya 5404fb9d1e Fix Linux open file descriptor count being inflated by 2 due to counting . and .. directory entries (#112)
Fix Linux open file descriptor count being inflated by 2 due to counting
"." and ".." directory entries

### Motivation:

The `linuxSystemMetrics()` function collects the number of open file
descriptors by enumerating the `/proc/self/fd` directory. The previous
implementation used a `readdir` loop that counted every entry in the
directory, which inadvertently included the `.` and `..` pseudo-entries.
This caused the reported metric to always be inflated by 2 above the
actual number of open file descriptors.

### Modifications:

- Updated `linuxSystemMetrics()` in `SystemMetricsMonitor+Linux.swift`
to check `d_name` and skip the `.` and `..` entries. This is done by
directly checking the bytes to avoid allocating a String for every
iteration.

- Added a new `openFileDescriptors()` test to
`LinuxDataProviderTests.swift` that mirrors the existing Darwin test by
verifying that opening `/dev/null` increases the open file descriptor
count by exactly 1.


### Result:
The `process_open_fds` metric on Linux will now accurately reflect the
exact number of file descriptors open by the process, aligning its
behavior with the Darwin implementation.
2026-04-27 17:08:05 +01:00
Vladimir Kukushkin 8abcf7c259 Add thread count to the service integration example (#111)
Add missing thread count to the service integration example.
2026-04-24 13:46:05 +01:00
Vladimir Kukushkin 3a60fcb0d1 Use task-local metrics factory in the service integration example (#110)
Use task-local metrics factory bootstrap in the example.

### Motivation:

`swift-metrics` now supports bootstrapping without the global state.
`swift-system-metrics` should have an up-to date example with all the
best practices.

### Modifications:

- Initialize `SystemMetricsMonitor` with a scoped task-local metrics
factory created by the `swift-otel`.

### Result:

`SystemMetricsMonitor` is initialized and operational without the global
metrics factory.
1.2.1
2026-04-22 12:14:09 +01:00
Vladimir Kukushkin c88a57b21e Make dependabot set label (#109)
Prompt: Make dependabot set  label

Claude output:
The file already has both changes applied:
- The schedule interval is already set to `"daily"`
- The label `"semver/none"` is already configured

No further changes needed — the dependabot.yml is already up to date.
2026-04-17 15:56:35 +01:00
dependabot[bot] 4ed54434f7 Bump swiftlang/github-workflows/.github/workflows/soundness.yml from 0.0.10 to 0.0.11 (#108)
Bumps
[swiftlang/github-workflows/.github/workflows/soundness.yml](https://github.com/swiftlang/github-workflows)
from 0.0.10 to 0.0.11.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/swiftlang/github-workflows/releases">swiftlang/github-workflows/.github/workflows/soundness.yml's
releases</a>.</em></p>
<blockquote>
<h2>0.0.11</h2>
<h2>What's Changed</h2>
<ul>
<li>Update all Swift package test defaults to 6.3 by <a
href="https://github.com/finagolfin"><code>@​finagolfin</code></a> in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/253">swiftlang/github-workflows#253</a></li>
<li>Android 6.3 support by <a
href="https://github.com/marcprux"><code>@​marcprux</code></a> in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/251">swiftlang/github-workflows#251</a></li>
<li>Add PR Dependency check workflow by <a
href="https://github.com/bkhouri"><code>@​bkhouri</code></a> in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/233">swiftlang/github-workflows#233</a></li>
<li>update NDK version by <a
href="https://github.com/justice-adams-apple"><code>@​justice-adams-apple</code></a>
in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/262">swiftlang/github-workflows#262</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/swiftlang/github-workflows/compare/0.0.10...0.0.11">https://github.com/swiftlang/github-workflows/compare/0.0.10...0.0.11</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/a487d5014a30e7e0a75f39a4d65dc7655a1855ad"><code>a487d50</code></a>
update NDK version (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/262">#262</a>)</li>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/f45407ca96925df11076921c153f0e59d7d30e7f"><code>f45407c</code></a>
Add PR Dependency check workflow (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/233">#233</a>)</li>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/42768536f44a0fd3ca41624752698844cd8493c2"><code>4276853</code></a>
Android 6.3 support (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/251">#251</a>)</li>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/531b7917e71e8c3b405045a13bf1dd3556b0a451"><code>531b791</code></a>
Update all Swift package test defaults to 6.3 (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/253">#253</a>)</li>
<li>See full diff in <a
href="https://github.com/swiftlang/github-workflows/compare/0.0.10...0.0.11">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=swiftlang/github-workflows/.github/workflows/soundness.yml&package-manager=github_actions&previous-version=0.0.10&new-version=0.0.11)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-17 10:11:36 +00:00
Vladimir Kukushkin 476ac0cde2 Update dependabot to daily schedule (#107)
Switching dependabot from weekly to daily.
2026-04-17 10:01:03 +00:00
Vladimir Kukushkin 61d8c71036 Suggest using MappingMetricsFactory from swift-metrics (#105)
Document the recommended way of customizing metric labels and dimensions
created by the Swift System Metrics.

### Motivation:

Swift System Metrics creates metric objects with specific labels. These
labels are in prometheus notation. To make Swift System Metrics
compatible with other metrics tools, we need a way to customize the
labels. Swift Metrics has recently received an updated with a metrics
factory providing a way to centrally adjust metric labels and dimensions
on the factory level.

### Modifications:

- The recommended way of customizing metric labels created by the Swift
System Metrics.

### Result:

Swift System Metrics users can customize system metric labels according
to the backend specs of their choice.
1.2.0
2026-04-15 11:45:52 +01:00
dependabot[bot] 132831de0d Bump swiftlang/github-workflows/.github/workflows/soundness.yml from 0.0.9 to 0.0.10 (#106)
Bumps
[swiftlang/github-workflows/.github/workflows/soundness.yml](https://github.com/swiftlang/github-workflows)
from 0.0.9 to 0.0.10.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/swiftlang/github-workflows/releases">swiftlang/github-workflows/.github/workflows/soundness.yml's
releases</a>.</em></p>
<blockquote>
<h2>0.0.10</h2>
<h2>What's Changed</h2>
<ul>
<li>Windows: Ensure Docker engine is running by <a
href="https://github.com/bkhouri"><code>@​bkhouri</code></a> in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/259">swiftlang/github-workflows#259</a></li>
<li>Add FreeBSD build job to swift_package_test workflow by <a
href="https://github.com/jakepetroules"><code>@​jakepetroules</code></a>
in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/257">swiftlang/github-workflows#257</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/swiftlang/github-workflows/compare/0.0.9...0.0.10">https://github.com/swiftlang/github-workflows/compare/0.0.9...0.0.10</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/3b5576d74703a6e4e30b49e2d2311313638c82e4"><code>3b5576d</code></a>
Add FreeBSD build job to swift_package_test workflow (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/257">#257</a>)</li>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/b337c7f02f4b38cbc2ce4de399ae417050ccd3e9"><code>b337c7f</code></a>
Windows: Ensure Docker engine is running (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/259">#259</a>)</li>
<li>See full diff in <a
href="https://github.com/swiftlang/github-workflows/compare/0.0.9...0.0.10">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=swiftlang/github-workflows/.github/workflows/soundness.yml&package-manager=github_actions&previous-version=0.0.9&new-version=0.0.10)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-14 20:08:30 +01:00
Rick Newton-Rogers d79a9f79a0 Drop Swift 6.0 (#102)
Motivation:

Swift 6.0 is no longer supported, we should bump the tools version and
remove it from our CI.

Modifications:

* Bump the Swift tools version to Swift 6.1
* Remove Swift 6.0 jobs where appropriate in main.yml, pull_request.yml

Result:

Code reflects our support window.
2026-04-14 13:58:03 +01:00
dependabot[bot] b7db51aa9a Bump swiftlang/github-workflows/.github/workflows/soundness.yml from 0.0.8 to 0.0.9 (#103)
Bumps
[swiftlang/github-workflows/.github/workflows/soundness.yml](https://github.com/swiftlang/github-workflows)
from 0.0.8 to 0.0.9.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/swiftlang/github-workflows/releases">swiftlang/github-workflows/.github/workflows/soundness.yml's
releases</a>.</em></p>
<blockquote>
<h2>0.0.9</h2>
<h2>What's Changed</h2>
<ul>
<li>When splitting lines for the cross-PR checkout also split on \r\n by
<a href="https://github.com/ahoppen"><code>@​ahoppen</code></a> in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/249">swiftlang/github-workflows#249</a></li>
<li>Fix template injection by <a
href="https://github.com/justice-adams-apple"><code>@​justice-adams-apple</code></a>
in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/247">swiftlang/github-workflows#247</a></li>
<li>Remove tailing comma in matrix JSON by <a
href="https://github.com/plemarquand"><code>@​plemarquand</code></a> in
<a
href="https://redirect.github.com/swiftlang/github-workflows/pull/254">swiftlang/github-workflows#254</a></li>
<li>Update default Xcode versions in workflow to 16.4, 26.3, and 26.4 by
<a href="https://github.com/shahmishal"><code>@​shahmishal</code></a> in
<a
href="https://redirect.github.com/swiftlang/github-workflows/pull/255">swiftlang/github-workflows#255</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/swiftlang/github-workflows/compare/0.0.8...0.0.9">https://github.com/swiftlang/github-workflows/compare/0.0.8...0.0.9</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/f84da042883848ad67aadd051dc322eec18660d3"><code>f84da04</code></a>
Update default Xcode versions in workflow to 16.4, 26.3, and 26.4 (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/255">#255</a>)</li>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/47c9717a9218ab60fe9fc6e957980d55fe949f1d"><code>47c9717</code></a>
Remove tailing comma in matrix JSON (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/254">#254</a>)</li>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/8e529b937e15ba0a65af9b492393704fe3f16bdf"><code>8e529b9</code></a>
Fix template injection (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/247">#247</a>)</li>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/58677410ce8ef88844850c908bcd830ad108c812"><code>5867741</code></a>
When splitting lines for the cross-PR checkout also split on \r\n (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/249">#249</a>)</li>
<li>See full diff in <a
href="https://github.com/swiftlang/github-workflows/compare/0.0.8...0.0.9">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=swiftlang/github-workflows/.github/workflows/soundness.yml&package-manager=github_actions&previous-version=0.0.8&new-version=0.0.9)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-14 09:37:06 +00:00
Vladimir Kukushkin c4fedeec5d Enable nightly tests on simulators to gather flakiness statistics (#104)
We need to gather some statistics on the flakiness of the simulators in
CI. This repo seems like a good candidate — the package is quite stable
and not that popular to raise questions.
2026-04-09 12:47:52 +00:00
Rick Newton-Rogers 082351a5ef Enable Swift 6.3 jobs in CI (#101)
Motivation:

Swift 6.3 has been released, we should add it to our CI coverage.

Modifications:

Add additional Swift 6.3 jobs where appropriate in main.yml,
pull_request.yml

Result:

Improved test coverage.
2026-04-01 14:19:43 +01:00
Roberto Adlich 758865b486 Add threadCount gauge (#98)
Add `threadCount` gauge w/ Linux and macOS implementations and
corresponding tests.

### Motivation:

Adds a `threadCount` gauge to track metrics for the number of threads in
the process.

### Modifications:

- Add macOS and Linux implementations of a `threadCount` gauge
- On macOS, uses `ProcessTaskInfo` API
- On Linux, uses `sysfs`
- Zombie threads are counted in both cases (reason: resources are in
use, and if not leaked those should be observer to decrement anyways,
soon matching what's "runnable", but if not, these alert of the leak)
- Adds tests, using XCTest to benefit from its default process isolation
(harder to test these with Swift Testing)
- Note that on macOS, tests don't reliably see resource clean-up without
even less reliable waits. So test gauge going up and down in Linux, but
only going up on macOS.
- Adds Grafana chart to the Example dashboard

### Result:

- Exports additional `threadCount` metric

### Testing:

```
$ swift-format lint -r --strict .
```

```
$ uname && xcrun swift test --enable-all-traits
Darwin
[...]
Test Suite 'swift-system-metricsPackageTests.xctest' started at 2026-02-23 19:12:57.942. Test Suite 'ThreadCountTests' started at 2026-02-23 19:12:57.942. Test Case '-[SystemMetricsTests.ThreadCountTests test_threadCount]' started. Test Case '-[SystemMetricsTests.ThreadCountTests test_threadCount]' passed (0.000 seconds). Test Suite 'ThreadCountTests' passed at 2026-02-23 19:12:57.943.
         Executed 1 test, with 0 failures (0 unexpected) in 0.000 (0.001) seconds
Test Suite 'swift-system-metricsPackageTests.xctest' passed at 2026-02-23 19:12:57.943.
         Executed 1 test, with 0 failures (0 unexpected) in 0.000 (0.001) seconds
Test Suite 'All tests' passed at 2026-02-23 19:12:57.943.
         Executed 1 test, with 0 failures (0 unexpected) in 0.000 (0.001) seconds
◇ Test run started.
[...]
✔ Test run with 16 tests in 3 suites passed after 2.009 seconds.
```

```
$ uname && swift test --enable-all-traits
Linux
[...]
Test Suite 'debug.xctest' started at 2026-02-24 03:15:37.877 Test Suite 'ThreadCountTests' started at 2026-02-24 03:15:37.877 Test Case 'ThreadCountTests.test_threadCount' started at 2026-02-24 03:15:37.877 Test Case 'ThreadCountTests.test_threadCount' passed (0.018 seconds) Test Suite 'ThreadCountTests' passed at 2026-02-24 03:15:37.896
         Executed 1 test, with 0 failures (0 unexpected) in 0.018 (0.018) seconds
Test Suite 'debug.xctest' passed at 2026-02-24 03:15:37.896
         Executed 1 test, with 0 failures (0 unexpected) in 0.018 (0.018) seconds
Test Suite 'All tests' passed at 2026-02-24 03:15:37.896
         Executed 1 test, with 0 failures (0 unexpected) in 0.018 (0.018) seconds
◇ Test run started.
[...]
✔ Test run with 13 tests in 3 suites passed after 1.269 seconds.
```

---------

Co-authored-by: Roberto Santos <ra_santos@apple.com>
1.1.0
2026-03-17 13:39:46 +01:00
dependabot[bot] 5cfeb57941 Bump swiftlang/github-workflows/.github/workflows/soundness.yml from 0.0.7 to 0.0.8 (#99)
Bumps
[swiftlang/github-workflows/.github/workflows/soundness.yml](https://github.com/swiftlang/github-workflows)
from 0.0.7 to 0.0.8.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/swiftlang/github-workflows/releases">swiftlang/github-workflows/.github/workflows/soundness.yml's
releases</a>.</em></p>
<blockquote>
<h2>0.0.8</h2>
<h2>What's Changed</h2>
<ul>
<li>Fix build warnings in the workflow for iOS by <a
href="https://github.com/kkebo"><code>@​kkebo</code></a> in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/173">swiftlang/github-workflows#173</a></li>
<li>Check if the locally installed Android NDK matches the wanted NDK
version by <a
href="https://github.com/finagolfin"><code>@​finagolfin</code></a> in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/235">swiftlang/github-workflows#235</a></li>
<li>Update installed version of static linux SDK to 0.1.0 when using
released toolchains by <a
href="https://github.com/owenv"><code>@​owenv</code></a> in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/241">swiftlang/github-workflows#241</a></li>
<li>Update the Xcode versions - 26.3 and 26.4b2 by <a
href="https://github.com/shahmishal"><code>@​shahmishal</code></a> in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/245">swiftlang/github-workflows#245</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/kkebo"><code>@​kkebo</code></a> made
their first contribution in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/173">swiftlang/github-workflows#173</a></li>
<li><a
href="https://github.com/finagolfin"><code>@​finagolfin</code></a> made
their first contribution in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/235">swiftlang/github-workflows#235</a></li>
<li><a href="https://github.com/owenv"><code>@​owenv</code></a> made
their first contribution in <a
href="https://redirect.github.com/swiftlang/github-workflows/pull/241">swiftlang/github-workflows#241</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/swiftlang/github-workflows/compare/0.0.7...0.0.8">https://github.com/swiftlang/github-workflows/compare/0.0.7...0.0.8</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/61db6917df4ec2ddeeb493757e2d1effd46af855"><code>61db691</code></a>
Update the Xcode versions - 26.3 and 26.4b2 (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/245">#245</a>)</li>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/d7f8c780c9994917d6088e165e0fee6fb0bd06a1"><code>d7f8c78</code></a>
Update installed version of static linux SDK to 0.1.0 (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/241">#241</a>)</li>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/bca81f75d7d1ae2474f1213169aab56dcad8961f"><code>bca81f7</code></a>
Revert Use local copy on action invocation (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/239">#239</a>)</li>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/27ad4acfa502b0cb8b901532e8294a14b7273988"><code>27ad4ac</code></a>
Add symlinks for backwards compatability (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/238">#238</a>)</li>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/555b8029955d1e91ed50768afb969805c796bdd6"><code>555b802</code></a>
Check if the locally installed Android NDK matches the wanted NDK
version (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/235">#235</a>)</li>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/c6fcbaf70a845126ec165107a2d509bda17a2fd1"><code>c6fcbaf</code></a>
Use local copy on action invocation (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/236">#236</a>)</li>
<li><a
href="https://github.com/swiftlang/github-workflows/commit/2b7c7405cd7ce3627f84fb0765c785f099d19715"><code>2b7c740</code></a>
Fix build warnings in the workflow for iOS (<a
href="https://redirect.github.com/swiftlang/github-workflows/issues/173">#173</a>)</li>
<li>See full diff in <a
href="https://github.com/swiftlang/github-workflows/compare/0.0.7...0.0.8">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=swiftlang/github-workflows/.github/workflows/soundness.yml&package-manager=github_actions&previous-version=0.0.7&new-version=0.0.8)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-11 10:04:13 +00:00
dependabot[bot] 8c68eb1da4 Bump actions/checkout from 4 to 6 (#95)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to
6.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/actions/checkout/releases">actions/checkout's
releases</a>.</em></p>
<blockquote>
<h2>v6.0.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Update README to include Node.js 24 support details and requirements
by <a href="https://github.com/salmanmkc"><code>@​salmanmkc</code></a>
in <a
href="https://redirect.github.com/actions/checkout/pull/2248">actions/checkout#2248</a></li>
<li>Persist creds to a separate file by <a
href="https://github.com/ericsciple"><code>@​ericsciple</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2286">actions/checkout#2286</a></li>
<li>v6-beta by <a
href="https://github.com/ericsciple"><code>@​ericsciple</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2298">actions/checkout#2298</a></li>
<li>update readme/changelog for v6 by <a
href="https://github.com/ericsciple"><code>@​ericsciple</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2311">actions/checkout#2311</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/checkout/compare/v5.0.0...v6.0.0">https://github.com/actions/checkout/compare/v5.0.0...v6.0.0</a></p>
<h2>v6-beta</h2>
<h2>What's Changed</h2>
<p>Updated persist-credentials to store the credentials under
<code>$RUNNER_TEMP</code> instead of directly in the local git
config.</p>
<p>This requires a minimum Actions Runner version of <a
href="https://github.com/actions/runner/releases/tag/v2.329.0">v2.329.0</a>
to access the persisted credentials for <a
href="https://docs.github.com/en/actions/tutorials/use-containerized-services/create-a-docker-container-action">Docker
container action</a> scenarios.</p>
<h2>v5.0.1</h2>
<h2>What's Changed</h2>
<ul>
<li>Port v6 cleanup to v5 by <a
href="https://github.com/ericsciple"><code>@​ericsciple</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2301">actions/checkout#2301</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/checkout/compare/v5...v5.0.1">https://github.com/actions/checkout/compare/v5...v5.0.1</a></p>
<h2>v5.0.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Update actions checkout to use node 24 by <a
href="https://github.com/salmanmkc"><code>@​salmanmkc</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2226">actions/checkout#2226</a></li>
<li>Prepare v5.0.0 release by <a
href="https://github.com/salmanmkc"><code>@​salmanmkc</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2238">actions/checkout#2238</a></li>
</ul>
<h2>⚠️ Minimum Compatible Runner Version</h2>
<p><strong>v2.327.1</strong><br />
<a
href="https://github.com/actions/runner/releases/tag/v2.327.1">Release
Notes</a></p>
<p>Make sure your runner is updated to this version or newer to use this
release.</p>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/checkout/compare/v4...v5.0.0">https://github.com/actions/checkout/compare/v4...v5.0.0</a></p>
<h2>v4.3.1</h2>
<h2>What's Changed</h2>
<ul>
<li>Port v6 cleanup to v4 by <a
href="https://github.com/ericsciple"><code>@​ericsciple</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2305">actions/checkout#2305</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/checkout/compare/v4...v4.3.1">https://github.com/actions/checkout/compare/v4...v4.3.1</a></p>
<h2>v4.3.0</h2>
<h2>What's Changed</h2>
<ul>
<li>docs: update README.md by <a
href="https://github.com/motss"><code>@​motss</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1971">actions/checkout#1971</a></li>
<li>Add internal repos for checking out multiple repositories by <a
href="https://github.com/mouismail"><code>@​mouismail</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1977">actions/checkout#1977</a></li>
<li>Documentation update - add recommended permissions to Readme by <a
href="https://github.com/benwells"><code>@​benwells</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2043">actions/checkout#2043</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/actions/checkout/blob/main/CHANGELOG.md">actions/checkout's
changelog</a>.</em></p>
<blockquote>
<h1>Changelog</h1>
<h2>v6.0.2</h2>
<ul>
<li>Fix tag handling: preserve annotations and explicit fetch-tags by <a
href="https://github.com/ericsciple"><code>@​ericsciple</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2356">actions/checkout#2356</a></li>
</ul>
<h2>v6.0.1</h2>
<ul>
<li>Add worktree support for persist-credentials includeIf by <a
href="https://github.com/ericsciple"><code>@​ericsciple</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2327">actions/checkout#2327</a></li>
</ul>
<h2>v6.0.0</h2>
<ul>
<li>Persist creds to a separate file by <a
href="https://github.com/ericsciple"><code>@​ericsciple</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2286">actions/checkout#2286</a></li>
<li>Update README to include Node.js 24 support details and requirements
by <a href="https://github.com/salmanmkc"><code>@​salmanmkc</code></a>
in <a
href="https://redirect.github.com/actions/checkout/pull/2248">actions/checkout#2248</a></li>
</ul>
<h2>v5.0.1</h2>
<ul>
<li>Port v6 cleanup to v5 by <a
href="https://github.com/ericsciple"><code>@​ericsciple</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2301">actions/checkout#2301</a></li>
</ul>
<h2>v5.0.0</h2>
<ul>
<li>Update actions checkout to use node 24 by <a
href="https://github.com/salmanmkc"><code>@​salmanmkc</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2226">actions/checkout#2226</a></li>
</ul>
<h2>v4.3.1</h2>
<ul>
<li>Port v6 cleanup to v4 by <a
href="https://github.com/ericsciple"><code>@​ericsciple</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2305">actions/checkout#2305</a></li>
</ul>
<h2>v4.3.0</h2>
<ul>
<li>docs: update README.md by <a
href="https://github.com/motss"><code>@​motss</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1971">actions/checkout#1971</a></li>
<li>Add internal repos for checking out multiple repositories by <a
href="https://github.com/mouismail"><code>@​mouismail</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1977">actions/checkout#1977</a></li>
<li>Documentation update - add recommended permissions to Readme by <a
href="https://github.com/benwells"><code>@​benwells</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2043">actions/checkout#2043</a></li>
<li>Adjust positioning of user email note and permissions heading by <a
href="https://github.com/joshmgross"><code>@​joshmgross</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2044">actions/checkout#2044</a></li>
<li>Update README.md by <a
href="https://github.com/nebuk89"><code>@​nebuk89</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2194">actions/checkout#2194</a></li>
<li>Update CODEOWNERS for actions by <a
href="https://github.com/TingluoHuang"><code>@​TingluoHuang</code></a>
in <a
href="https://redirect.github.com/actions/checkout/pull/2224">actions/checkout#2224</a></li>
<li>Update package dependencies by <a
href="https://github.com/salmanmkc"><code>@​salmanmkc</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/2236">actions/checkout#2236</a></li>
</ul>
<h2>v4.2.2</h2>
<ul>
<li><code>url-helper.ts</code> now leverages well-known environment
variables by <a href="https://github.com/jww3"><code>@​jww3</code></a>
in <a
href="https://redirect.github.com/actions/checkout/pull/1941">actions/checkout#1941</a></li>
<li>Expand unit test coverage for <code>isGhes</code> by <a
href="https://github.com/jww3"><code>@​jww3</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1946">actions/checkout#1946</a></li>
</ul>
<h2>v4.2.1</h2>
<ul>
<li>Check out other refs/* by commit if provided, fall back to ref by <a
href="https://github.com/orhantoy"><code>@​orhantoy</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1924">actions/checkout#1924</a></li>
</ul>
<h2>v4.2.0</h2>
<ul>
<li>Add Ref and Commit outputs by <a
href="https://github.com/lucacome"><code>@​lucacome</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1180">actions/checkout#1180</a></li>
<li>Dependency updates by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>- <a
href="https://redirect.github.com/actions/checkout/pull/1777">actions/checkout#1777</a>,
<a
href="https://redirect.github.com/actions/checkout/pull/1872">actions/checkout#1872</a></li>
</ul>
<h2>v4.1.7</h2>
<ul>
<li>Bump the minor-npm-dependencies group across 1 directory with 4
updates by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1739">actions/checkout#1739</a></li>
<li>Bump actions/checkout from 3 to 4 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1697">actions/checkout#1697</a></li>
<li>Check out other refs/* by commit by <a
href="https://github.com/orhantoy"><code>@​orhantoy</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1774">actions/checkout#1774</a></li>
<li>Pin actions/checkout's own workflows to a known, good, stable
version. by <a href="https://github.com/jww3"><code>@​jww3</code></a> in
<a
href="https://redirect.github.com/actions/checkout/pull/1776">actions/checkout#1776</a></li>
</ul>
<h2>v4.1.6</h2>
<ul>
<li>Check platform to set archive extension appropriately by <a
href="https://github.com/cory-miller"><code>@​cory-miller</code></a> in
<a
href="https://redirect.github.com/actions/checkout/pull/1732">actions/checkout#1732</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/actions/checkout/commit/de0fac2e4500dabe0009e67214ff5f5447ce83dd"><code>de0fac2</code></a>
Fix tag handling: preserve annotations and explicit fetch-tags (<a
href="https://redirect.github.com/actions/checkout/issues/2356">#2356</a>)</li>
<li><a
href="https://github.com/actions/checkout/commit/064fe7f3312418007dea2b49a19844a9ee378f49"><code>064fe7f</code></a>
Add orchestration_id to git user-agent when ACTIONS_ORCHESTRATION_ID is
set (...</li>
<li><a
href="https://github.com/actions/checkout/commit/8e8c483db84b4bee98b60c0593521ed34d9990e8"><code>8e8c483</code></a>
Clarify v6 README (<a
href="https://redirect.github.com/actions/checkout/issues/2328">#2328</a>)</li>
<li><a
href="https://github.com/actions/checkout/commit/033fa0dc0b82693d8986f1016a0ec2c5e7d9cbb1"><code>033fa0d</code></a>
Add worktree support for persist-credentials includeIf (<a
href="https://redirect.github.com/actions/checkout/issues/2327">#2327</a>)</li>
<li><a
href="https://github.com/actions/checkout/commit/c2d88d3ecc89a9ef08eebf45d9637801dcee7eb5"><code>c2d88d3</code></a>
Update all references from v5 and v4 to v6 (<a
href="https://redirect.github.com/actions/checkout/issues/2314">#2314</a>)</li>
<li><a
href="https://github.com/actions/checkout/commit/1af3b93b6815bc44a9784bd300feb67ff0d1eeb3"><code>1af3b93</code></a>
update readme/changelog for v6 (<a
href="https://redirect.github.com/actions/checkout/issues/2311">#2311</a>)</li>
<li><a
href="https://github.com/actions/checkout/commit/71cf2267d89c5cb81562390fa70a37fa40b1305e"><code>71cf226</code></a>
v6-beta (<a
href="https://redirect.github.com/actions/checkout/issues/2298">#2298</a>)</li>
<li><a
href="https://github.com/actions/checkout/commit/069c6959146423d11cd0184e6accf28f9d45f06e"><code>069c695</code></a>
Persist creds to a separate file (<a
href="https://redirect.github.com/actions/checkout/issues/2286">#2286</a>)</li>
<li><a
href="https://github.com/actions/checkout/commit/ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493"><code>ff7abcd</code></a>
Update README to include Node.js 24 support details and requirements (<a
href="https://redirect.github.com/actions/checkout/issues/2248">#2248</a>)</li>
<li><a
href="https://github.com/actions/checkout/commit/08c6903cd8c0fde910a37f88322edcfb5dd907a8"><code>08c6903</code></a>
Prepare v5.0.0 release (<a
href="https://redirect.github.com/actions/checkout/issues/2238">#2238</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/actions/checkout/compare/v4...v6">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4&new-version=6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-17 17:55:25 +00:00
Honza Dvorsky 542e97463a Enable dependabot and switch GHA references to tags (#94)
### Motivation:

For better control over GitHub workflows, switch over to a tags-based
dependency.

### Modifications:

- Switch to tags
- Enable dependabot to get weekly update checks

### Result:

More streamlined and controlled GHA dependency updates.
2026-02-17 17:26:59 +00:00
Kohei Ota (inductor) f206d506dc [CI] Add automated release workflow using swift-temporal-sdk (#93)
Integrate swift-temporal-sdk's reusable auto-release workflow for
automated semantic versioning releases. Update CONTRIBUTING.md with a
link to the workflow documentation.

### Motivation

- Automate the release process using semantic versioning labels,
reducing manual overhead and ensuring consistent versioning across
releases.

### Modifications

- Add .github/workflows/auto-release.yml that uses swift-temporal-sdk's
reusable workflow
- Update CONTRIBUTING.md with automated release process documentation
linking to swift-temporal-sdk's workflow README

### Result

- When PRs are merged with semver labels (semver/patch, semver/minor),
the workflow automatically creates GitHub releases. Major releases
require manual creation.

### Test Plan

- Workflow will be validated after merge by labeling PRs with semver
labels and verifying that releases are created automatically.
2026-02-10 10:06:40 +00:00
Vladimir Kukushkin c21c329a89 Remove unsafe flags (#90)
Remove unsafe `-require-explicit-sendable` flag.

### Motivation:

Existence of the flag prevents the package tags from being used.

### Modifications:

The flag removed from the Package.swift.

### Result:

Package could be used with a tag.
1.0.1
2026-01-22 15:12:35 +00:00
Vladimir Kukushkin a7ea829574 Fix security advisories reporting url (#88)
### Motivation

The URL was wrong, it was copy-pasted from another repo and we didn't
update the URL.

### Modifications

Fix the URL.

### Result

Correct URL.

### Test Plan

N/A
1.0.0
2026-01-16 12:15:02 +01:00
Honza Dvorsky 6d5f3643c6 Pre-1.0 suggestions (#87)
### Motivation:

Pre-1.0 cleanup opportunity 

### Modifications:

A bunch of small suggestions. They're for your consideration, so feel
free to tell me which ones to revert if needed.

### Result:

Repo ready for 1.0
2026-01-14 16:53:10 +01:00
Vladimir Kukushkin 76ff2b1072 Do not put example service name into the dashboard config (#84)
Remove swift-system-metrics ServiceIntegration example name from the
example dashboard provisioning.

### Motivation:

With the specific service name hardcoded in the dashboard provisioning
config, it is not compatible with other projects where people might want
to just copy-paste this config. All other metrics (CPU%, fds) already
use values across all the reported dimensions.

### Modifications:

Removed `service_name="ServiceIntegrationExample"` filter from the
memory consumption dashboard visualization.

### Result:

Memory dashboard configuration no longer shows memory usage only for the
`ServiceIntegrationExample` service. Any project adopting
`SystemMetricsMonitor` can now copy-paste the config as-is and get the
Process System Metrics dashboard configured automatically in their
Grafana.
2026-01-14 13:20:29 +00:00
Vladimir Kukushkin ea05c18fc1 Increase the default collection interval (#83)
Fixes #82 

### Motivation:

Most monitoring tools do not collect the data frequently, so there is no
need to update the gauges every 2 seconds if tools are collecting data
every 5-30-60 seconds. 15 seconds is a good middle ground.

### Modifications:

Default interval value and the corresponding docs are updated.

### Result:

With the default configuration, system metrics are collected every 15
seconds.
2026-01-14 14:15:37 +01:00
Joseph Heck bffbbc47be [docs] organization, style, and grammar updates (#81)
### Motivation:

Review of content against docs style guides for upcoming 1.0 release

### Modifications:

- adds in default docs curation for the public types and articles
- rework language for Apple style guide as well as active voice, present
tense, and American english spelling choices. Fixes some typos as well.
- shifting content into getting started, revising descriptions, removing
passive voice
- manually linking to metrics API (hosted at SPI)

Before:
```
   --- Experimental coverage output enabled. ---
                | Abstract        | Curated         | Code Listing
Types           | 100% (2/2)      | 50% (1/2)       | 50% (1/2)
Members         | 100% (6/6)      | 0.0% (0/6)      | 0.0% (0/6)
Globals         | 100% (1/1)      | 100% (1/1)      | 100% (1/1)
```

After:
```
   --- Experimental coverage output enabled. ---
                | Abstract        | Curated         | Code Listing
Types           | 100% (2/2)      | 100% (2/2)      | 50% (1/2)
Members         | 100% (6/6)      | 100% (6/6)      | 0.0% (0/6)
Globals         | 100% (1/1)      | 100% (1/1)      | 0.0% (0/1)
```

To quickly preview locally:
```
gh pr checkout 81
swift package add-dependency https://github.com/swiftlang/swift-docc-plugin --from 1.0.0
swift package --disable-sandbox preview-documentation --target SystemMetrics
```
ex:
<img width="1629" height="1105" alt="Screenshot 2026-01-07 at 4 22
33 PM"
src="https://github.com/user-attachments/assets/36304914-f859-4651-9034-b53d81d4b0c4"
/>

Biggest notable change that you we may not want to run with - I trimmed
down what was at the top level, shifting away from the format that
swift-configuration used, because that information felt overwhelming (it
felt like a giant README trying to shove too much in there), and moved
the getting started into a concise article that I curated inline.

I haven't added, but could, a quick walk through article with image
snapshots w/ `Examples/ServiceIntegration` to show setting it up and
seeing the metrics being reported in a local grafana instance, although
I think the README in that directory is already pretty darned good and
gets to the core for someone who just wants to see it work to get a
sense of what's included.

---------

Co-authored-by: Honza Dvorsky <honza@apple.com>
2026-01-13 08:39:21 -08:00
Vladimir Kukushkin 79fcb6c637 SSM-0002: rename package to swift-system-metrics (#80)
Rename the `swift-metrics-extras` package and repository to
`swift-system-metrics` to accurately represent its purpose.

### Motivation:

The package name `swift-metrics-extras` suggests a collection of various
metrics-related utilities, but the package contains only one component
collecting and reporting process system metrics. This creates confusion
for potential users and does not accurately describe the package's
purpose. A more descriptive name would make it easier for users to
discover and understand what the package does.

### Modifications:

- (outside of this PR) Repository is already renamed to
`[swift-system-metrics](https://github.com/apple/swift-system-metrics)`.
- References to the repo name is updated across the docs.

### Result:

- https://github.com/apple/swift-system-metrics exists.
- https://github.com/apple/swift-metrics-extras redirects to
https://github.com/apple/swift-system-metrics.
- Existing projects referencing Swift Metrics Extras keep working.
2026-01-06 14:38:20 +00:00
barrytomasini 394e826997 Implements a metrics provider for Darwin (#78)
This branch adds a Darwin metrics provider, using macOS system APIs.

### Motivation:

Someone developing or deploying a service on macOS should be able to
take advantage of the same system metrics that are available to Swift
processes running on Linux. (#72)

### Modifications:

- Replaced the stub implementation for Darwin, which previously returned
`nil`
- Implemented unit tests for metrics like CPU time, resident memory, &
open file descriptors

### Result:

Feature parity between macOS and Linux for collecting system metrics.

---------

Co-authored-by: Vladimir Kukushkin <kukushechkin@mac.com>
2025-12-19 14:39:12 +00:00
Vladimir Kukushkin c117f845b9 Add a Grafana dashboard to the Service Integration example (#77)
Add Grafana integration with a provisioned Process System Metrics
dashboard to the Service Integration example.

### Motivation:

Process System Metrics collected and exported in this package ultimately
should be used in a monitoring dashboard. While it is common for
operates to be opinionated about the their dashboards, we also want to
help new users with observability adoption by providing an example
dashboard they can use as an inspiration or directly add to their
project.

### Modifications:

- OTel exporting is added to the `ServiceIntegration` example via
`swift-otel` package.
- A simple Grafana dashboard utilizing the metrics implemented by the
`SystemMetricsMonitor` added to the example.
- A docker-compose deployment added to the example.

### Result:

Users can deploy a sample Grafana dashboard with SystemMetricsMonitor
metrics and use it as an inspiration for creating monitoring for their
services.

<img width="1118" height="1042" alt="Screenshot 2025-12-17 at 17 38 23"
src="https://github.com/user-attachments/assets/584735c0-8823-4b5b-a609-1b8856ee3cc3"
/>
2025-12-18 13:37:32 +00:00
Vladimir Kukushkin ece01fd2a2 Build example projects (#76)
Build the Examples in CI.

### Motivation:

`swift-metrics-extras` now has an `Example/ServiceIntegration`, which
depends on the package, but is not verified in the CI.

### Modifications:

- `Scripts/test-examples.sh` added (inspired by the
[`swift-configuration/Scripts/test-examples.sh`](https://github.com/apple/swift-configuration/blob/main/Scripts/test-examples.sh),
but the structure is different and this one is more simple).
- `pull_request` and `main` workflows use shared
`apple/swift-nio/.github/workflows/swift_test_matrix.yml@main` to run
the script.

### Result:

`Example/ServiceIntegration` is being built in CI on Linux
2025-12-18 11:18:33 +00:00
Vladimir Kukushkin 4c90e01c73 Improve Linux metrics collection implementation comments (#75)
Improve Linux metrics collection implementation comments

### Motivation:

Implementation details comments were not updated during the `rusage`
adoption for CPU usage metrics.

### Modifications:

Comments updated to accurately reflect the APIs used to collect Linux
metrics.

### Result:

Comments now accurately reflect the APIs used to collect Linux metrics.
2025-12-18 11:06:09 +00:00
Vladimir Kukushkin 5f09354b2a Upgrade GitHub Actions for Node 24 compatibility (#79)
Per [GitHub's
announcement](https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/),
Node 20 is being deprecated and runners will begin using Node 24 by
default starting March 4th, 2026.

### Motivation:

Upgrade GitHub Actions to their latest versions to ensure compatibility
with Node 24, as Node 20 will reach end-of-life in April 2026.

### Modifications:

`actions/checkout@v4` -> `actions/checkout@v6`

### Result:

Ready for Node 20 deprecation.
2025-12-18 10:54:12 +00:00
Salman Chishti 75fc10feeb Upgrade GitHub Actions for Node 24 compatibility (#74)
## Summary

Upgrade GitHub Actions to their latest versions to ensure compatibility
with Node 24, as Node 20 will reach end-of-life in April 2026.

## Changes

| Action | Old Version(s) | New Version | Release | Files |
|--------|---------------|-------------|---------|-------|
| `actions/checkout` |
[`v4`](https://github.com/actions/checkout/releases/tag/v4) |
[`v6`](https://github.com/actions/checkout/releases/tag/v6) |
[Release](https://github.com/actions/checkout/releases/tag/v6) |
pull_request_label.yml |

## Context

Per [GitHub's
announcement](https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/),
Node 20 is being deprecated and runners will begin using Node 24 by
default starting March 4th, 2026.

### Why this matters

- **Node 20 EOL**: April 2026
- **Node 24 default**: March 4th, 2026
- **Action**: Update to latest action versions that support Node 24

### Security Note

Actions that were previously pinned to commit SHAs remain pinned to SHAs
(updated to the latest release SHA) to maintain the security benefits of
immutable references.

### Testing

These changes only affect CI/CD workflow configurations and should not
impact application functionality. The workflows should be tested by
running them on a branch before merging.

Signed-off-by: Salman Muin Kayser Chishti <13schishti@gmail.com>
2025-12-17 21:27:25 +00:00
Vladimir Kukushkin af43fc955f [SSM-0002] Rename the package to better reflect its purpose (#70)
Introduce a proposal for renaming the package to better reflect its
purpose.

### Motivation:

The package name `swift-metrics-extras` suggests a collection of various
metrics-related utilities, but the package contains only one component
collecting and reporting process system metrics. This creates confusion
for potential users and does not accurately describe the package's
purpose. A more descriptive name would make it easier for users to
discover and understand what the package does.

### Modifications:

"SSM-0002: rename the package" proposal doc added

### Result:

A proposal document added.
2025-12-12 11:29:09 +01:00
Vladimir Kukushkin 2f5844baa0 Calculate and report more granular process_cpu_seconds_total (#71) 2025-12-11 14:18:29 +01:00
Vladimir Kukushkin 28aba29240 [SSM-0001] New public API implementation (#66)
Implementation draft the SSM-0001 proposal the
https://github.com/apple/swift-metrics-extras/pull/65

---------

Co-authored-by: Honza Dvorsky <honza@apple.com>
2025-12-09 14:15:56 +01:00
Rick Newton-Rogers a26ce8e955 Add static SDK CI workflow (#47)
Add static SDK CI workflow which runs on commits to PRs, merges to main
and daily on main.

---------

Co-authored-by: Vladimir Kukushkin <kukushechkin@mac.com>
2025-12-04 10:38:43 +00:00
Vladimir Kukushkin 6867490fb4 [SSM-0001] Public API redesign (#65)
Public API proposal doc and implementation.

### Motivation:

As part of the 1.0 release we would like to revise the public API to
simplify adoption and maintenance:
* Reduce public API to a minimum to make it easier to support more
platforms and metrics gathering strategies.
* Decouple `swift-metrics-extras` public interface from the global
`MetricsSystem`.
* Add compatibility with `swift-service-lifecycle`

### Modifications:

"SSM-0001: `swift-metrics-extras` revised public API to support 1.0
roadmap" proposal doc added

### Result:

A proposal doc added.

---------

Co-authored-by: Honza Dvorsky <honza@apple.com>
2025-12-03 17:46:12 +00:00
Vladimir Kukushkin 470017fc4e add support for compiling against musl (#68)
A follow-up for the #34 by @lovetodream, rebasing to the latest changes.

Tested with the CI:
https://github.com/apple/swift-metrics-extras/actions/runs/19898816027/job/57036490920?pr=68

---------

Co-authored-by: Timo <38291523+lovetodream@users.noreply.github.com>
2025-12-03 17:33:52 +00:00
Vladimir Kukushkin 6b41025747 Make the Proposal Process easier discoverable (#67) 2025-11-28 08:54:09 +00:00
Vladimir Kukushkin 18b56d0a4e Introduce proposals process (#63)
For non-trivial changes that affect the public API, the Swift Metrics
Extras project adopts a lightweight version of the [Swift
Evolution](https://github.com/apple/swift-evolution/blob/main/process.md)
process.

### Motivation:

Writing a proposal first helps discuss multiple possible solutions
early, apply useful feedback from other contributors, and avoid
reimplementing the same feature multiple times.

### Modifications:

"Proposals" topic and a proposal template added to the documentation.

### Result:

Proposals can now be submitted to the Swift Metrics Extras.
2025-11-13 17:04:56 +01:00
Vladimir Kukushkin 01553aa3e2 Migrate to Swift Testing (#60)
Migrating `swift-metrics-extras` from XCTest to Swift Testing

### Motivation

Swift Testing is a modern alternative to XCTest. Swift Server Ecosystem
packages should serve as reference implementations for modern Swift
features and best practices.

### Modifications

- Almost 1-to-1 migration of test suites, tests, and assertions to Swift
Testing syntax with XCTest import removed

### Result

Successfully executes 6 tests with `swift test --disable-xctest`.
2025-11-03 16:26:46 +00:00
Vladimir Kukushkin a506777fb9 Drop Swift 5 support, update toolchain to 6.0 (#59)
Make Swift 6.0 the minimum support version.

### Motivation:

`swift-metrics-extras` supports 3 latest Swift releases, which is at
this point 6.0, 6.1 and 6.2. Swift 5 is no longer supported.

### Modifications:

- Package.swift swift tools
- CI configs
- Set package `.swiftLanguageMode` to `v5` as a migration to Swift 6
workaround

### Result:

Swift 5 is no longer supported.
2025-11-03 14:53:54 +01:00
Melissa Kilby c8b43a0eb1 chore: restrict GitHub workflow permissions - future-proof (#58)
See https://github.com/swiftlang/github-workflows/issues/167 for
additional context

This approach aligns with security best practices, as detailed in the
following documentation:

-
https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions
-
https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#defining-access-for-the-github_token-scopes
-
https://openssf.org/blog/2024/08/12/mitigating-attack-vectors-in-github-workflows/


The default GITHUB_TOKEN permissions are defined at the repository
level. This PR modifies the workflow-level overrides to conform to
OpenSSF best practices -> defense in depth.

Allow me to quote OpenSSF:

https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions

> The highest score is awarded when the permissions definitions in each
workflow's yaml file are set as read-only at the top level and the
required write permissions are declared at the run-level.”

> Remediation steps
> - Set top-level permissions as read-all or contents: read as described
in GitHub's documentation.
> - Set any required write permissions at the job-level. Only set the
permissions required for that job; do not set permissions: write-all at
the job level.


Compare to the LLVM project:

Top-level: contents read, e.g.
https://github.com/swiftlang/llvm-project/blob/next/.github/workflows/build-ci-container-windows.yml#L3-L4
-> this makes it future-proof

Job-level: Allow write permissions as needed, e.g.
https://github.com/swiftlang/llvm-project/blob/next/.github/workflows/build-ci-container-windows.yml#L53-L58

Signed-off-by: Melissa Kilby <mkilby@apple.com>
2025-10-20 16:13:14 +02:00
Raphael 225a64416e Enable release mode builds (#55) 2025-07-30 08:30:07 +02:00
Rick Newton-Rogers 2053c5b10b Drop Swift 5.9 (#54)
Motivation:

Swift 5.9 is no longer supported, we should bump the tools version and
remove it from our CI.

Modifications:

* Bump the Swift tools version to Swift 5.10
* Remove Swift 5.9 jobs where appropriate in main.yml, pull_request.yml

Result:

Code reflects our support window.
2025-05-07 05:40:55 +00:00
Jason Toffaletti 959ec9d658 add Sendable annotations and use withUnsafeTemporaryAllocation (#53)
add Sendable annotations and use withUnsafeTemporaryAllocation

### Motivation:

I'd like to use swift 6 mode without needing `@preconcurrency`.
While testing with swift 6.1 I noticed a warning about
`String(cString:)` being deprecated and saw an opportunity to use
[withUnsafeTemporaryAllocation](https://developer.apple.com/documentation/swift/withunsafetemporaryallocation(of:capacity:_:)).

### Modifications:

Sendable annotations fix warnings with swift 6 mode.
withUnsafeTemporaryAllocation simplifies part of the code and removes a
heap allocation

### Result:

code like this will compile in swift 6 mode without needing
`@preconcurrency`

```
extension SystemMetrics.Configuration {
    /// `SystemMetrics.Configuration` with Prometheus style labels.
    ///
    /// For more information see `SystemMetrics.Configuration`
    public static let prometheus = SystemMetrics.Configuration(
        labels: .init(
            prefix: "process_",
            virtualMemoryBytes: "virtual_memory_bytes",
            residentMemoryBytes: "resident_memory_bytes",
            startTimeSeconds: "start_time_seconds",
            cpuSecondsTotal: "cpu_seconds_total",
            maxFds: "max_fds",
            openFds: "open_fds",
            cpuUsage: "cpu_usage"
        )
    )
}
```
2025-05-02 10:42:49 +02:00