Skip to content

feat(trace): support SGLANG_TRACE_LEVEL env var for startup trace level#24716

Merged
ishandhanani merged 1 commit into
sgl-project:mainfrom
sytianhe:tianhez/sglang-trace-level-env-var
May 11, 2026
Merged

feat(trace): support SGLANG_TRACE_LEVEL env var for startup trace level#24716
ishandhanani merged 1 commit into
sgl-project:mainfrom
sytianhe:tianhez/sglang-trace-level-env-var

Conversation

@sytianhe
Copy link
Copy Markdown
Contributor

@sytianhe sytianhe commented May 8, 2026

Motivation

global_trace_level defaults to 3, which includes high-volume scheduler spans (decode_loop, chunked_prefill) emitted every iteration. There is currently no way to set a lower level at startup — operators must either call the /set_trace_level HTTP endpoint after launch or accept the default verbosity.

Modifications

  • python/sglang/srt/observability/trace.py: initialize global_trace_level from SGLANG_TRACE_LEVEL env var (default 3) using the existing get_int_env_var helper
  • test/registered/unit/observability/test_trace.py: add unit test verifying the env var is read at module init
  • docs/references/production_request_trace.md: document the startup env var option alongside the existing runtime HTTP endpoint

Accuracy Tests

No model output changes — this only affects which spans are emitted.

Speed Tests and Profiling

Lower trace levels reduce span generation overhead. No benchmark required for this change.

Checklist

🤖 Generated with Claude Code

global_trace_level defaults to 3, which includes high-volume scheduler
spans (decode_loop, chunked_prefill) emitted every iteration. Allow
operators to set a lower level at startup via SGLANG_TRACE_LEVEL without
requiring a server restart or HTTP call after launch.

The runtime /set_trace_level endpoint remains available for dynamic
adjustment after startup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@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!

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 8, 2026
@sufeng-buaa
Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@sufeng-buaa
Copy link
Copy Markdown
Collaborator

ci 'stage-a-test-cpu' is ok

@ishandhanani ishandhanani merged commit 95985f9 into sgl-project:main May 11, 2026
174 of 199 checks passed
LucQueen pushed a commit to LucQueen/sglang that referenced this pull request May 12, 2026
…el (sgl-project#24716)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
xjpang pushed a commit to xjpang/sglang that referenced this pull request May 13, 2026
…el (sgl-project#24716)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
zijiexia added a commit to zijiexia/sglang that referenced this pull request Jun 4, 2026
…evel

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants