[Auto Sync] Update request_metrics_exporter.py (20251230) (#16183)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Scott Lee <scottjlee@users.noreply.github.com>
This commit is contained in:
Yineng Zhang
2025-12-30 09:09:41 -10:00
committed by GitHub
parent 4bc2f2e0bc
commit 00e607111a

View File

@@ -12,6 +12,10 @@ from sglang.srt.server_args import ServerArgs
logger = logging.getLogger(__name__)
# Fields that should always be excluded from request parameters
# because they contain non-JSON-serializable objects (e.g., ImageData, tensors)
ALWAYS_EXCLUDE_FIELDS = {"image_data", "video_data", "audio_data", "input_embeds"}
class RequestMetricsExporter(ABC):
"""Abstract base class for exporting request-level performance metrics to a data destination."""
@@ -35,7 +39,11 @@ class RequestMetricsExporter(ABC):
request_params = {}
for field in dataclasses.fields(obj):
field_name = field.name
if field_name not in self.obj_skip_names:
# Skip fields in obj_skip_names or fields that are always excluded (not JSON serializable)
if (
field_name not in self.obj_skip_names
and field_name not in ALWAYS_EXCLUDE_FIELDS
):
value = getattr(obj, field_name)
# Convert to serializable format
if value is not None: