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_CLASSwhen 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_ MARKDOWN - Value for
LABEL_INPUT_MIME_TYPEwhen the request was text/markdown (current sole supported reader). - INPUT_
MIME_ NONE - Value for
LABEL_INPUT_MIME_TYPEwhen the Content-Type header was absent. - INPUT_
MIME_ UNSUPPORTED - Value for
LABEL_INPUT_MIME_TYPEwhen 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_TYPEwhen the conversion producedBlockNoteJSON. - OUTPUT_
MIME_ NONE - Value for
LABEL_OUTPUT_MIME_TYPEwhen no output was produced (any error path). - OUTPUT_
MIME_ OXA - Value for
LABEL_OUTPUT_MIME_TYPEwhen the conversion producedoxa.devJSON. - PATH_
UNKNOWN - Value for
LABEL_PATHwhen no route was matched by the router. - RESULT_
CLIENT_ ERROR - Value for
LABEL_RESULTwhen a conversion fails due to a client error. - RESULT_
SERVER_ ERROR - Value for
LABEL_RESULTwhen a conversion fails due to a server error. - RESULT_
SUCCESS - Value for
LABEL_RESULTwhen a conversion succeeds.
Functions§
- build_
recorder - Builds a configured
PrometheusRecorderand itsPrometheusHandlewithout 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.