Skip to content

[model-gateway] add mcp and discovery metrics#15156

Merged
slin1237 merged 3 commits intomainfrom
metric-n/11
Dec 15, 2025
Merged

[model-gateway] add mcp and discovery metrics#15156
slin1237 merged 3 commits intomainfrom
metric-n/11

Conversation

@slin1237
Copy link
Copy Markdown
Collaborator

Checklist

Add metrics for service discovery and worker registration tracking:

Metrics added:
- smg_discovery_registrations_total{source, result}
- smg_discovery_deregistrations_total{source, reason}
- smg_discovery_workers_discovered{source} (gauge)

Label constants added:
- Registration results: success, failed, duplicate
- Deregistration reasons: health_check_failed, timeout, manual,
  shutdown, pod_deleted

Instrumented locations:
- K8s service discovery (handle_pod_event, handle_pod_deletion)
- Static config initialization (InitializeWorkersFromConfig)

Performance: Single mutex lock acquisition for both state update and
gauge count to avoid redundant locking in async context.
Add metrics for MCP tool execution tracking:

Metrics instrumented:
- smg_mcp_tool_calls_total{model, tool_name, result}
- smg_mcp_tool_duration_seconds{model, tool_name}
- smg_mcp_tool_iterations_total{model}
- smg_mcp_servers_active (gauge)

Implementation:
- Instrument regular responses tool loop (tool_loop.rs)
- Instrument harmony responses tool loop (responses.rs)
- Track active MCP servers in mcp_registration.rs step
- Add model_id parameter to execute_mcp_tools for proper labeling

Performance: Timing uses Instant which has nanosecond-level overhead.
Static config worker initialization is not discovery - it's just
making requests to model endpoints and creating model aliases.
Remove the misplaced discovery metrics.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@slin1237 slin1237 merged commit 7b9156c into main Dec 15, 2025
62 of 67 checks passed
@slin1237 slin1237 deleted the metric-n/11 branch December 15, 2025 06:54
Liwansi added a commit to iforgetmyname/sglang that referenced this pull request Dec 15, 2025
…n_eagle3_npu

* 'main' of https://github.com/sgl-project/sglang: (89 commits)
  [model-gateway] Remove legacy RouterMetrics and Rename SmgMetrics to Metrics and smg_labels to metrics_labels (sgl-project#15160)
  [diffusion] fix: fix video model sp when resolution is not specified (sgl-project#15047)
  [diffusion] fix: fix pytorch non-writable array warning (sgl-project#15017)
  [diffusion] fix: cache dit with parallel (sgl-project#15163)
  chore: change npu pr-test a2 runner (sgl-project#15152)
  [Feature] Fuse mrope all in 1 kernel (sgl-project#14906)
  Fix num running requests (load) wrong cleared for ongoing requests (sgl-project#15116)
  Fused two elementwise kernels for k_nope and k_pe concat (sgl-project#14862)
  fix: adding date and fixing release name issue (sgl-project#15174)
  [CPU] Add Gemma3RMSNorm kernel in sgl-kernel and add ut (sgl-project#9324)
  feature: PR wheel (sgl-project#15170)
  [diffusion] model: support mutli-image input and qwen-image-edit-2509 (sgl-project#15005)
  fix CompressedTensorsW8A8Int8 min_capability (sgl-project#13914)
  Tiny improve summary text in `bench_one_batch_server.py` (sgl-project#15158)
  [model-gateway] add mcp and discovery metrics (sgl-project#15156)
  fix: move ci-bot (sgl-project#15154)
  Fix import warnings (sgl-project#15144)
  ci: adding errors to Github summary (sgl-project#14778)
  [model-gateway] Add streaming metrics for harmony gRPC router (sgl-project#15147)
  [model-gateway] upgrade axum and axum server (sgl-project#15146)
  ...

# Conflicts:
#	python/sglang/srt/server_args.py
tonyluj pushed a commit to openanolis/sglang that referenced this pull request Dec 17, 2025
YChange01 pushed a commit to YChange01/sglang that referenced this pull request Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant