From 97c087778b024a0538c7662168fa3ca218a296fb Mon Sep 17 00:00:00 2001 From: "minke.yu" Date: Sat, 7 Nov 2026 11:35:03 +0800 Subject: [PATCH] observability: harden flush span attributes * Normalize the host-pool layout to a string (a None attribute would make the OTel SDK drop the whole flush span). * Drop any remaining None-valued flush attributes for the same reason. --- python/sglang/srt/managers/cache_controller.py | 3 ++- python/sglang/srt/observability/batch_telemetry.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/python/sglang/srt/managers/cache_controller.py b/python/sglang/srt/managers/cache_controller.py index 208aeb4851..b306db3880 100644 --- a/python/sglang/srt/managers/cache_controller.py +++ b/python/sglang/srt/managers/cache_controller.py @@ -907,7 +907,8 @@ class HiCacheController: ) batch_telemetry.flush_note("sglang.flush_io_backend", self.io_backend) batch_telemetry.flush_note( - "sglang.flush_layout", getattr(self.mem_pool_host, "layout", None) + "sglang.flush_layout", + str(getattr(self.mem_pool_host, "layout", None) or ""), ) batch_telemetry.flush_note( "sglang.flush_ack_queue_before", len(self.ack_write_queue) diff --git a/python/sglang/srt/observability/batch_telemetry.py b/python/sglang/srt/observability/batch_telemetry.py index 9caad04834..abee9f31ef 100644 --- a/python/sglang/srt/observability/batch_telemetry.py +++ b/python/sglang/srt/observability/batch_telemetry.py @@ -1470,6 +1470,9 @@ class BackupFlushTracer: for name, value in self.counts.items(): attrs["sglang.flush_" + name] = int(value) attrs.update(self.attrs) + # OTel rejects None; keep a single malformed dimension from dropping the + # whole span. + attrs = {k: v for k, v in attrs.items() if v is not None} try: from opentelemetry import trace as otel_trace