observability: publish the generated forward-pass-metrics endpoint to the bags (#33337)

When --forward-pass-metrics-ipc-name is left unset the reporter generates an
endpoint and has to hand it to external consumers (the documented contract is
that they read it back from the server config). That readback is the scheduler's
get_internal_state, which already reports get_context().resolved_server_args_dict(),
so the write moves to get_context().override and the read alongside it to
get_observability() — the endpoint still shows up in /server_info's
internal_states, and the ServerArgs instance stops being a message bus.

The test's server_args stand-in (a SimpleNamespace with a hand-rolled override)
becomes a real published config, so the reporter exercises the same accessors as
production.

Writer ratchet 19 -> 18.
This commit is contained in:
Cheng Wan
2026-08-02 21:24:11 -07:00
committed by GitHub
parent 0b3e8bedd1
commit aa3bbbc6e8
3 changed files with 30 additions and 22 deletions
@@ -26,7 +26,7 @@ from sglang.srt.observability.metrics_collector import (
SchedulerStats,
compute_routing_key_stats,
)
from sglang.srt.runtime_context import get_spec
from sglang.srt.runtime_context import get_context, get_observability, get_spec
from sglang.srt.utils.device_timer import DeviceTimer
from sglang.srt.utils.scheduler_status_logger import SchedulerStatusLogger
@@ -215,11 +215,11 @@ class SchedulerMetricsReporter:
self.scheduler._fpm_worker_id = (
self.scheduler.server_args.forward_pass_metrics_worker_id
)
base_endpoint = self.scheduler.server_args.forward_pass_metrics_ipc_name
base_endpoint = get_observability().forward_pass_metrics_ipc_name
if base_endpoint is None:
ipc_path = tempfile.NamedTemporaryFile(delete=False).name
base_endpoint = f"ipc://{ipc_path}"
self.scheduler.server_args.override(
get_context().override(
"metrics_reporter.ipc_endpoint",
forward_pass_metrics_ipc_name=base_endpoint,
)