feat: log request when e2e latency exceeds the specified value (#15759)
Co-authored-by: qiuxuan.lzw <qiuxuan.lzw@alibaba-inc.com> Co-authored-by: Xiaoyu Zhang <35585791+BBuf@users.noreply.github.com>
This commit is contained in:
@@ -139,6 +139,7 @@ class Envs:
|
||||
SGLANG_LOG_FORWARD_ITERS = EnvBool(False)
|
||||
SGLANG_LOG_MS = EnvBool(False)
|
||||
SGLANG_DISABLE_REQUEST_LOGGING = EnvBool(False)
|
||||
SGLANG_LOG_REQUEST_EXCEEDED_MS = EnvInt(-1)
|
||||
|
||||
# SGLang CI
|
||||
SGLANG_IS_IN_CI = EnvBool(False)
|
||||
|
||||
@@ -20,6 +20,7 @@ from datetime import datetime
|
||||
from functools import lru_cache
|
||||
from typing import TYPE_CHECKING, Any, Optional, Set, Tuple, Union
|
||||
|
||||
from sglang.srt.environ import envs
|
||||
from sglang.srt.utils.common import get_bool_env_var
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -47,6 +48,7 @@ class RequestLogger:
|
||||
self.metadata: Tuple[Optional[int], Optional[Set[str]], Optional[Set[str]]] = (
|
||||
self._compute_metadata()
|
||||
)
|
||||
self.log_exceeded_ms = envs.SGLANG_LOG_REQUEST_EXCEEDED_MS.get()
|
||||
|
||||
def configure(
|
||||
self,
|
||||
@@ -100,6 +102,10 @@ class RequestLogger:
|
||||
if not self.log_requests:
|
||||
return
|
||||
|
||||
e2e_latency_ms = out["meta_info"]["e2e_latency"] * 1000
|
||||
if self.log_exceeded_ms > 0 and e2e_latency_ms < self.log_exceeded_ms:
|
||||
return
|
||||
|
||||
max_length, skip_names, out_skip_names = self.metadata
|
||||
if self.log_requests_format == "json":
|
||||
log_data = {
|
||||
|
||||
Reference in New Issue
Block a user