llm-runtime-metrics (Python)
Python bindings for request metrics and Prometheus export.
Install from PyPI as llm-runtime-metrics.
Import in Python as:
import llm_runtime_metrics
The supported package root focuses on the request-metrics workflow.
S3 request-log proxy
Set s3_proxy_url to route S3 requests through an HTTP forward proxy, such as
a sidecar listening on http://127.0.0.1:3128:
factory = RequestMetricsFactory(
request_log_enabled=True,
s3=True,
s3_bucket="request-logs",
s3_region="us-east-1",
s3_proxy_url="http://127.0.0.1:3128",
)
The S3 bucket, region, signing, and endpoint remain unchanged. For HTTPS S3
endpoints, the proxy must support HTTP CONNECT. Omit s3_proxy_url for a
direct connection. compact_s3_parquet_to_local accepts the same option for
downloads. Use s3_endpoint only for an S3-compatible endpoint override.
In request-log records, model_name is stored as supplied. org_id is hashed
without a salt. provided_session_id is hashed without a salt so the same ID
has the same digest across deployments. request_log_hash_salt applies only to
the token-block hashes in total_hashes; without it, those hashes are unkeyed.
Timing, token counts, flags, and other metadata are stored as plain values.
Pass b10_request_id to new_request to store its unkeyed, domain-separated
hash (an empty string is stored as null); hash_b10_request_id computes the same digest for joins. The digest is
the lowercase hex of blake3(b"pm-b10-request-id-v1" + raw_id.encode()), with no
key, and is stable across versions. Call
set_routed_workers on the request before it finishes to record the prefill
and decode worker ids and DP ranks; each call replaces all four values, so
omitted arguments are stored as null. anonymize_parquet drops b10_request_id
and replaces worker ids with dense per-file ids by default. Each column is
numbered on its own, so after anonymizing, prefill worker 1 and decode worker 1
are not the same machine, and ids do not match across files. The worker id and
DP rank columns are meaningful only on rows with __version__ 0.0.20 or later;
on older rows, null means "not recorded", not "not routed".
Set component_name on RequestMetricsFactory to identify the type of
component that wrote each request log, for example "frontend" or "worker".
The library generates component_id once per process and shares it among all
factories in that process. Both fields are stored as plain text in JSON and
Parquet records; component_name is optional.
Add LLM Metrics To An Existing Prometheus Server
from prometheus_client import CollectorRegistry, start_http_server
from llm_runtime_metrics import (
REQUEST_FEATURE_IMAGE,
REQUEST_FEATURE_TOOLS,
RequestMetricsCollector,
RequestMetricsFactory,
)
# Reuse your existing registry if you already have one.
registry = CollectorRegistry()
factory = RequestMetricsFactory(
request_log_enabled=False,
metric_prefix="llm_runtime",
metrics_window_seconds=60.0,
metrics_quantiles=[0.5, 0.9, 0.99],
)
# Registers a custom collector that pulls fresh samples from `factory` at scrape time.
RequestMetricsCollector(
factory,
base_labels={"service": "text-generation", "engine": "vllm"},
registry=registry,
)
# If your app already exposes /metrics, wire this into that server instead.
start_http_server(8000, registry=registry)
# Example lifecycle hooks in your inference code:
def on_request_start(prompt_token_ids: list[int]):
features = REQUEST_FEATURE_TOOLS | REQUEST_FEATURE_IMAGE
return factory.new_request(prompt_token_ids, features=features)
def on_stream_step(req_metrics, full_output_token_ids: list[int], cached_tokens: int | None):
# Use `is_diff=False` when passing cumulative token ids.
req_metrics.record_tokens(full_output_token_ids, cached_tokens=cached_tokens, is_diff=False)
def on_request_success(req_metrics):
req_metrics.success()
def on_request_cancel(req_metrics):
req_metrics.cancel()
The exported request latency distributions include request_metrics_ttft_ms,
request_metrics_time_to_fifth_token_ms,
request_metrics_first_to_fifth_token_itl_ms, and request_metrics_itl_ms.
request_metrics_time_to_fifth_token_ms is the elapsed time from request start
until the fifth output token is observed by record_tokens.
request_metrics_first_to_fifth_token_itl_ms is the elapsed time between
observing the first and fifth output tokens.
Request logs include mean_output_tokens_per_step: output tokens divided by the
number of nonempty record_tokens updates. It is null when no output tokens were
recorded. One update is the observed step; callers that batch multiple engine
iterations into one update get tokens per update, not tokens per engine iteration.
The inflight gauges also include early-decode pressure between the first and
fifth output token:
current_inflight_first_to_fifth_token_requests,
mean_inflight_first_to_fifth_token_requests,
current_inflight_first_to_fifth_token_input_tokens, and
mean_inflight_first_to_fifth_token_input_tokens. The input-token gauges count
prompt tokens attached to requests that have emitted at least one output token
but have not emitted their fifth token yet.
Available request feature bits:
REQUEST_FEATURE_NONEREQUEST_FEATURE_XGRAMMARREQUEST_FEATURE_TOOLSREQUEST_FEATURE_IMAGE
If you need plain text output instead of a collector, call:
text = factory.prometheus_strfmt({"service": "text-generation", "engine": "vllm"})
Metadata
Release files for llm-runtime-metrics 0.0.21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llm_runtime_metrics-0.0.21.tar.gz | 114.1 kB | Without provenance | Details for llm_runtime_metrics-0.0.21.tar.gz |
Built distributions (wheels)
Total release size: 144.2 MB
Release files / llm_runtime_metrics-0.0.21.tar.gz
| Download URL | llm_runtime_metrics-0.0.21.tar.gz |
|---|---|
| Size | 114.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9200aed81758c33ab3d617c8cf9a39c5e74c8da9165ad32b42dddf6363ce197e
|
|
BLAKE2b-256 checksum How to use checksums |
6f21f0d648ee335dfdccd3a663cb135698090bc6f4f5c04600d60158f9fd1cc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp314-cp314t-musllinux_1_2_x86_64.whl
| Download URL | llm_runtime_metrics-0.0.21-cp314-cp314t-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
cf53bff38dcd6fdf4631a06c0be0ee3d145235780ab0f63d3e112c4a1de7e114
|
|
BLAKE2b-256 checksum How to use checksums |
8d05df227b59169a6322a00d2197c32a20d147f3234159a9225d5616360c2c71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp314-cp314t-musllinux_1_2_i686.whl
| Download URL | llm_runtime_metrics-0.0.21-cp314-cp314t-musllinux_1_2_i686.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-32 |
|
SHA-256 checksum How to use checksums |
5c76fd4509c8b91b7abee216a80788df108806f01fccc73bc99d14abbe9ee572
|
|
BLAKE2b-256 checksum How to use checksums |
75602a05d34d4d26414989253b3a8917509111750eea2d97febe9524b3d651cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp314-cp314t-musllinux_1_2_armv7l.whl
| Download URL | llm_runtime_metrics-0.0.21-cp314-cp314t-musllinux_1_2_armv7l.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ ARMv7l |
|
SHA-256 checksum How to use checksums |
422373e81271506feff312bcb5a7a4a0d91e5996003e527e8feceb3271695f87
|
|
BLAKE2b-256 checksum How to use checksums |
9a2ea5adcfea14474ebb9edebc5cff6f241b9e1da76a04d860fa8bf99378bb99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp314-cp314t-musllinux_1_2_aarch64.whl
| Download URL | llm_runtime_metrics-0.0.21-cp314-cp314t-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 7.0 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ ARM64 |
|
SHA-256 checksum How to use checksums |
00591e82021437ed7921f785eb27adb3a540ce04d4694c4ccab8b345a8afcfb4
|
|
BLAKE2b-256 checksum How to use checksums |
486db5e48884f839ac41e67385c89f2fe576bcec31faaa0fdc0002b206a9ffdb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | llm_runtime_metrics-0.0.21-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 6.6 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
c5024eb72975ef872b602a3315b1155ee4ad539165d6cdd3bf44ae51baf0c8b7
|
|
BLAKE2b-256 checksum How to use checksums |
17ade949c6af82e71e5bb547ad4a5b0e04431f7b6079b3bc87a108878845a58f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
| Download URL | llm_runtime_metrics-0.0.21-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl |
|---|---|
| Size | 8.3 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ PowerPC 64-le |
|
SHA-256 checksum How to use checksums |
2e3ab0fa232686ecf7841631a13291508d1164391cb873c7e335960c0d3c844b
|
|
BLAKE2b-256 checksum How to use checksums |
c7d5222c776d6b7d292489626bca8af0a98387eeb0b5b828cfc3f592dad2d1ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp314-cp314t-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | llm_runtime_metrics-0.0.21-cp314-cp314t-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 7.4 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-32 |
|
SHA-256 checksum How to use checksums |
521d91993d7ac7dc42f3caf3f2ae88d36c9e8da4767d6c1e274541e95b23969e
|
|
BLAKE2b-256 checksum How to use checksums |
b5bab3c14e4b69446de06833d6f6ee293fc2782d47fd56a950472306ddde5b3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp314-cp314t-macosx_11_0_arm64.whl
| Download URL | llm_runtime_metrics-0.0.21-cp314-cp314t-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.8 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
34238650d6cabb26480573fba4236c37b67e67317c3f4c61d45dc4819a5e55e1
|
|
BLAKE2b-256 checksum How to use checksums |
fef77a2bb88d4fedcc84af8d62885b93cf68f6edf00b6256a7cbf702c52c29dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp314-cp314t-macosx_10_12_x86_64.whl
| Download URL | llm_runtime_metrics-0.0.21-cp314-cp314t-macosx_10_12_x86_64.whl |
|---|---|
| Size | 6.1 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
8252a099770bc84cf6c6776af5c5e4840467616144210314a2c97d64f8242bdc
|
|
BLAKE2b-256 checksum How to use checksums |
e411d19c42418623adbb6754be082622bbded8c717cdaf43518d2dcc79f57aeb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp310-abi3-win_amd64.whl
| Download URL | llm_runtime_metrics-0.0.21-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
c853013f7f3e02381bb53563f5f004eeac7bb7679dba493f39bde615e874b165
|
|
BLAKE2b-256 checksum How to use checksums |
884273b5288d095122216de8abada0ed479eb2ae2a4ca83e2f41d6a4c1301001
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | llm_runtime_metrics-0.0.21-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
53d0ce46eb5a7479d535f0a3856a988778c471a21e505518ea6b64aa34b2dc9a
|
|
BLAKE2b-256 checksum How to use checksums |
016c3c31a8ffafeb6314f22545eeac662069291dd49cf5e6f9e3e29288eb913a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp310-abi3-musllinux_1_2_i686.whl
| Download URL | llm_runtime_metrics-0.0.21-cp310-abi3-musllinux_1_2_i686.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
8c9b61a313a93b1daa10b0d824e82d1c49915c1ea151abfd5f0d1a0c7b644906
|
|
BLAKE2b-256 checksum How to use checksums |
fc881d51cd1169515deb28a4005a907b3b818ba8f27778257d013c69e2702d07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp310-abi3-musllinux_1_2_armv7l.whl
| Download URL | llm_runtime_metrics-0.0.21-cp310-abi3-musllinux_1_2_armv7l.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.10 Linux musl 1.2+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
d1699df1744e5840880f16de13151b068ec05d37a794194cfcd4469615220eee
|
|
BLAKE2b-256 checksum How to use checksums |
7813f600a806fc6e36ba6b5337fe605474c7be73bd1757374d5b3107140ac480
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp310-abi3-musllinux_1_2_aarch64.whl
| Download URL | llm_runtime_metrics-0.0.21-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 7.0 MB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
d8983d3cfce03095ff8469b65ed3aa7888ef33bad867a02a7cc3ba784be97f3b
|
|
BLAKE2b-256 checksum How to use checksums |
11e1425c53057936f6057c5efed7399897141f8c23d656a5f3cd956a2cfbbb7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp310-abi3-manylinux_2_28_ppc64le.whl
| Download URL | llm_runtime_metrics-0.0.21-cp310-abi3-manylinux_2_28_ppc64le.whl |
|---|---|
| Size | 8.3 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ PowerPC 64-le abi3 |
|
SHA-256 checksum How to use checksums |
3138c2e5ba83a7cef31342ec520d8306c56ba51e78fce301eba900e7f9480fa5
|
|
BLAKE2b-256 checksum How to use checksums |
b5022fac44b8a04750aa4b7f4b34aa3f50f4f9a09d5de0cbbf5dc6e62877d9d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp310-abi3-manylinux_2_28_armv7l.whl
| Download URL | llm_runtime_metrics-0.0.21-cp310-abi3-manylinux_2_28_armv7l.whl |
|---|---|
| Size | 6.7 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
1b509795dff59164803cfab2cba06398adb19549c2db798d9f8747fe07edad64
|
|
BLAKE2b-256 checksum How to use checksums |
2eddf1fe1ea84ebe82a9e7a798a608260c96778fa5de748fb8d1b7934f8181d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | llm_runtime_metrics-0.0.21-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 6.8 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
89f91ec5bae1738c22dedd36316622b73f713d49f4017a8d95b67e9001116aa3
|
|
BLAKE2b-256 checksum How to use checksums |
6dfc62cdc2d249b02844be42b37f59793a15d05ee14111bc9789d38d7479b80b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | llm_runtime_metrics-0.0.21-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 6.7 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
fbbcc39f38f92f8e5ce6655b37e19af03671785b268829f1e8ab6a0ea2488252
|
|
BLAKE2b-256 checksum How to use checksums |
6bff310d2897b69e9091d86d3359c362c69779db32ad1c89b9e59ca13ad3c618
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | llm_runtime_metrics-0.0.21-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 7.4 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
7da2a60e24fac92371425aa284c383ef1cd44d202c592780fa5f84e445397215
|
|
BLAKE2b-256 checksum How to use checksums |
c9a68ec23f4fbcceb4f7915b75681f7fe1014d7f62e5c75436564652356d9e7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | llm_runtime_metrics-0.0.21-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.8 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e61b163c282ca84c4529d376db03150f089ca8beba9298f968a1ba1e643202d1
|
|
BLAKE2b-256 checksum How to use checksums |
79d5fd87e4950f1d4660e4fc30c3e6a66ab961b5ce646ebb125a36401faaee63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Release files / llm_runtime_metrics-0.0.21-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | llm_runtime_metrics-0.0.21-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 6.1 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
5f89c50230d2e7a8bfafc6da19768b00ebc95d859c90f3576441b7b359b93c30
|
|
BLAKE2b-256 checksum How to use checksums |
47915cfa2ead8b56ac974b2fa3fa11ebed4badc67d85b98ff815714fdb48bb9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.15.0
|
Security for llm-runtime-metrics 0.0.21
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.