Skip to main content

Module metrics

Module metrics 

Source
Expand description

Prometheus metrics for the docspec-http server.

Each pod exposes its own /metrics endpoint. The Prometheus server scrapes each pod independently — no aggregation happens in-process.

§Design

This module owns all metric-name and label constants. Middleware (see middleware) records values; this module only declares and describes them. Call install_global once at startup before accepting requests, then mount the closure returned by metrics_handler at /metrics.

Modules§

middleware
Tower middleware for recording HTTP-level Prometheus metrics.

Constants§

CONVERSION_DURATION_BUCKETS
Latency histogram buckets for document conversion duration, in seconds.
CONVERSION_OUTPUT_BYTES_BUCKETS
Size histogram buckets for conversion output bytes.
ERROR_CLASS_NONE
Value for LABEL_ERROR_CLASS when no error occurred.
HTTP_BODY_SIZE_BUCKETS
Body-size histogram buckets for HTTP request bodies, in bytes.
HTTP_LATENCY_BUCKETS
Latency histogram buckets for HTTP request duration, in seconds.
INPUT_MIME_HTML
Value for LABEL_INPUT_MIME_TYPE when the request was text/html.
INPUT_MIME_MARKDOWN
Value for LABEL_INPUT_MIME_TYPE when the request was text/markdown.
INPUT_MIME_NONE
Value for LABEL_INPUT_MIME_TYPE when the Content-Type header was absent.
INPUT_MIME_UNSUPPORTED
Value for LABEL_INPUT_MIME_TYPE when the Content-Type header was present but not a supported reader format.
LABEL_ERROR_CLASS
Label key for the error class when a conversion fails.
LABEL_INPUT_MIME_TYPE
Label key for the input MIME type of the conversion request.
LABEL_METHOD
Label key for the HTTP request method (GET, POST, …).
LABEL_OUTPUT_MIME_TYPE
Label key for the output MIME type produced by the conversion.
LABEL_PATH
Label key for the matched route path pattern.
LABEL_RESULT
Label key for the conversion outcome category.
LABEL_STATUS
Label key for the HTTP response status code.
METRIC_CONVERSIONS_TOTAL
Counter: total number of document conversions.
METRIC_CONVERSION_DURATION_SECONDS
Histogram: document conversion duration in seconds.
METRIC_CONVERSION_OUTPUT_BYTES
Histogram: document conversion output size in bytes.
METRIC_HTTP_REQUESTS_TOTAL
Counter: total number of HTTP requests received.
METRIC_HTTP_REQUEST_BODY_BYTES
Histogram: HTTP request body size in bytes.
METRIC_HTTP_REQUEST_DURATION_SECONDS
Histogram: HTTP request latency in seconds.
OUTPUT_MIME_BLOCKNOTE
Value for LABEL_OUTPUT_MIME_TYPE when the conversion produced BlockNote JSON.
OUTPUT_MIME_HTML
Value for LABEL_OUTPUT_MIME_TYPE when the conversion produced HTML.
OUTPUT_MIME_NONE
Value for LABEL_OUTPUT_MIME_TYPE when no output was produced (any error path).
OUTPUT_MIME_OXA
Value for LABEL_OUTPUT_MIME_TYPE when the conversion produced oxa.dev JSON.
PATH_UNKNOWN
Value for LABEL_PATH when no route was matched by the router.
RESULT_CLIENT_ERROR
Value for LABEL_RESULT when a conversion fails due to a client error.
RESULT_SERVER_ERROR
Value for LABEL_RESULT when a conversion fails due to a server error.
RESULT_SUCCESS
Value for LABEL_RESULT when a conversion succeeds.

Functions§

build_recorder
Builds a configured PrometheusRecorder and its PrometheusHandle without installing it globally.
install_global
Installs the Prometheus recorder globally and registers HELP text for every metric.
metrics_handler
Returns a clone-safe handler closure that renders Prometheus metrics as an HTTP response with the correct Content-Type.