Skip to content

Commit 9841a9b

Browse files
LouisHaftmannclaude
andcommitted
fix(metrics): register process collector only on Linux
prometheus 0.14 compiles `process_collector` only on Linux, so the server failed to build on macOS. Register the collector and assert its series only on Linux, and mark the `process_*` metrics as Linux only. Closes #324 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7561558 commit 9841a9b

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎src/metrics.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub(crate) enum LookupResult {
2424
impl Metrics {
2525
pub(crate) fn new() -> Result<Self, prometheus::Error> {
2626
let registry = Registry::new();
27+
// prometheus only ships the process collector on Linux.
28+
#[cfg(target_os = "linux")]
2729
registry.register(Box::new(
2830
prometheus::process_collector::ProcessCollector::for_self(),
2931
))?;

‎src/tests/cache_protocol.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ async fn counts_uploads_hits_misses_and_stored_bytes() {
302302
"prometheus text format"
303303
);
304304
let metrics = response.text().await.unwrap();
305+
#[cfg(target_os = "linux")]
305306
assert!(
306307
metrics.contains("process_start_time_seconds"),
307308
"process metrics are wired up"

‎website/src/content/docs/metrics.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ scrape_configs:
2424
2525
## Exposed metrics
2626
27-
| Metric | Type | Description |
28-
| -------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------- |
29-
| `cache_requests_total{result="hit"\|"miss"}` | counter | Cache download-URL lookups by result. A restore-key prefix match counts as a `hit`. |
30-
| `cache_uploads_total` | counter | Cache uploads finalized into cache entries. |
31-
| `cache_storage_bytes` | gauge | Total size of finalized cache payloads currently in storage. |
32-
| `process_*` | gauge | Default process metrics: CPU, resident and virtual memory, open file descriptors, threads, and `process_start_time_seconds` (uptime). |
27+
| Metric | Type | Description |
28+
| -------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
29+
| `cache_requests_total{result="hit"\|"miss"}` | counter | Cache download-URL lookups by result. A restore-key prefix match counts as a `hit`. |
30+
| `cache_uploads_total` | counter | Cache uploads finalized into cache entries. |
31+
| `cache_storage_bytes` | gauge | Total size of finalized cache payloads currently in storage. |
32+
| `process_*` | gauge | Default process metrics: CPU, resident and virtual memory, open file descriptors, threads, and `process_start_time_seconds` (uptime). Linux only. |
3333

3434
Rates are derived in [PromQL](https://prometheus.io/docs/prometheus/latest/querying/basics/), e.g. requests per minute and hit ratio:
3535

0 commit comments

Comments
 (0)