inference/research
verifiedhigh · 0.93updated 2026-10-05

Xinference xinference/core/metrics.py - the aioprometheus metric registry for supervisor and worker

repo

Fields

id
sources/w5e-xinference-core-metrics
Publisher
xorbitsai
Kind
repo
Accessed
2026-10-05
notes
Read at main 2026-10-05. 1306 lines. Uses aioprometheus (async Prometheus), NOT prometheus_client: metrics are module-level singletons declared as name = Counter("xinference:...", "doc", [labelnames]) with buckets as a tuple argument. 73 distinct metric names are declared here. launch_metrics_export_server() (line 1266) builds a separate FastAPI app with app.add_route("/metrics", metrics) from aioprometheus.asgi.starlette, served by uvicorn in a daemon thread; it first deregisters the names in _SUPERVISOR_ONLY_METRICS so the worker endpoint does not emit empty HELP/TYPE headers. Worker startup gate: is_metrics_disabled() (XINFERENCE_DISABLE_METRICS=1) else start the export server when metrics_exporter_host or metrics_exporter_port is set.

Notes

Read at main 2026-10-05. 1306 lines. Uses aioprometheus (async Prometheus), NOT prometheus_client: metrics are module-level singletons declared as name = Counter("xinference:...", "doc", [labelnames]) with buckets as a tuple argument. 73 distinct metric names are declared here. launch_metrics_export_server() (line 1266) builds a separate FastAPI app with app.add_route("/metrics", metrics) from aioprometheus.asgi.starlette, served by uvicorn in a daemon thread; it first deregisters the names in _SUPERVISOR_ONLY_METRICS so the worker endpoint does not emit empty HELP/TYPE headers. Worker startup gate: is_metrics_disabled() (XINFERENCE_DISABLE_METRICS=1) else start the export server when metrics_exporter_host or metrics_exporter_port is set.

Cross-references

This record references no other records.