fix(opentelemetry): JSON-serialize dict metadata fields for OTEL span attributes (#27451) (#27455)

Squash-merged by litellm-agent from Anai-Guo's PR.
This commit is contained in:
Tai An 2026-05-08 03:31:49 -07:00 committed by GitHub
parent 98cd057f38
commit 760e55826a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -876,8 +876,13 @@ class OpenTelemetry(CustomLogger):
"mcp_tool_call_metadata",
"vector_store_request_metadata",
]:
if md.get(key) is not None:
common_attrs[f"metadata.{key}"] = str(md[key])
value = md.get(key)
if value is None:
continue
if isinstance(value, (dict, list)):
common_attrs[f"metadata.{key}"] = safe_dumps(value)
else:
common_attrs[f"metadata.{key}"] = str(value)
# get hidden params
hidden_params = getattr(std_log, "hidden_params", None) or (std_log or {}).get(