Skip to main content

Module metrics

Module metrics 

Source
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:

NameTypeLabelsDescription
osp_requests_totalCountermethod, bucket, statusTotal requests
osp_request_errors_totalCountermethod, bucket, errorTotal errors
osp_active_connectionsGaugeCurrent open connections
osp_request_duration_secondsHistogrammethod, bucketLatency
osp_transfer_bytes_totalCounterdirection (rx/tx), bucketBytes transferred
osp_presigned_url_hits_totalCounterbucketPresigned URL hits
osp_memory_bytesGaugeRSS memory usage
osp_build_infoGaugeversion, rustcStatic 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 Lazy statics to initialise and record the build-info gauge.
serve_metrics
Spawn a minimal Tokio HTTP server on port that serves /metrics.
update_memory_gauge
Read /proc/self/status on Linux to obtain RSS; no-op on other platforms.