Expand description
Prometheus metrics registry and collection helpers.
Enabled only when the metrics Cargo feature is active.
Exposes a global [Registry] with the following instruments:
| Name | Type | Labels | Description |
|---|---|---|---|
osp_requests_total | Counter | method, bucket, status | Total requests |
osp_request_errors_total | Counter | method, bucket, error | Total errors |
osp_active_connections | Gauge | — | Current open connections |
osp_request_duration_seconds | Histogram | method, bucket | Latency |
osp_transfer_bytes_total | Counter | direction (rx/tx), bucket | Bytes transferred |
osp_presigned_url_hits_total | Counter | bucket | Presigned URL hits |
osp_memory_bytes | Gauge | — | RSS memory usage |
osp_build_info | Gauge | version, rustc | Static build metadata |
Statics§
- ACTIVE_
CONNECTIONS - Number of currently active (in-flight) connections.
- BUILD_
INFO - Static build-info gauge — always 1, used to expose version labels.
- MEMORY_
BYTES - Resident Set Size in bytes (sampled at scrape time via
update_memory_gauge). - PRESIGNED_
URL_ HITS_ TOTAL - Total presigned-URL hits per bucket.
- PRESIGNED_
URL_ REJECTED_ TOTAL - Total presigned-URL rejections (usage limit exceeded).
- REGISTRY
- The global Prometheus registry for all OSP metrics.
- REQUESTS_
TOTAL - Total number of proxied requests, labelled by HTTP method, bucket and upstream response status code.
- REQUEST_
DURATION_ SECONDS - End-to-end request latency in seconds, labelled by method and bucket.
- REQUEST_
ERRORS_ TOTAL - Total number of requests that resulted in an error (4xx/5xx or internal).
- RESPONSE_
SIZE_ BYTES - Response body size histogram (bytes), labelled by method and bucket.
- TRANSFER_
BYTES_ TOTAL - Bytes transferred, labelled by direction (
rx= client->proxy,tx= proxy->client) and bucket.
Functions§
- gather_
metrics - Encode the global registry to the Prometheus text format.
- init_
metrics - Force all
Lazystatics to initialise and record the build-info gauge. - serve_
metrics - Spawn a minimal Tokio HTTP server on
portthat serves/metrics. - update_
memory_ gauge - Read
/proc/self/statuson Linux to obtain RSS; no-op on other platforms.