mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-29 06:33:28 +00:00
fix(otel): honor redact_user_api_key_info for span metadata and team attributes
When litellm.redact_user_api_key_info is True, OTEL spans still emitted metadata.user_api_key_* attributes (hash, user id, email, team id) and stamped team_id/team_alias onto every child span. Filter span metadata through redact_user_api_key_info and skip team attributes when the flag is set. Fixes #36758
This commit is contained in:
parent
e0e3523246
commit
3cc4091730
1 changed files with 5 additions and 1 deletions
|
|
@ -1516,6 +1516,8 @@ class OpenTelemetry(OTELGenAISemconvMixin, CustomLogger):
|
|||
in ``standard_logging_object.metadata``; propagating that to every
|
||||
span only adds noise that makes traces look mis-instrumented.
|
||||
"""
|
||||
if litellm.redact_user_api_key_info is True:
|
||||
return
|
||||
if team_id:
|
||||
self.safe_set_attribute(
|
||||
span=span,
|
||||
|
|
@ -2411,7 +2413,9 @@ class OpenTelemetry(OTELGenAISemconvMixin, CustomLogger):
|
|||
#############################################
|
||||
############ LLM CALL METADATA ##############
|
||||
#############################################
|
||||
metadata: Final = standard_logging_payload["metadata"]
|
||||
from litellm.litellm_core_utils.redact_messages import redact_user_api_key_info
|
||||
|
||||
metadata: Final = redact_user_api_key_info(metadata=dict(standard_logging_payload["metadata"]))
|
||||
for key, value in metadata.items():
|
||||
self.safe_set_attribute(span=span, key=f"metadata.{key}", value=value)
|
||||
decision: Final = metadata.get("routing_decision")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue