mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
log provider specific metadata as a span
This commit is contained in:
parent
177f670c7d
commit
3e2a1fe0aa
2 changed files with 46 additions and 1 deletions
|
@ -515,6 +515,9 @@ class LangFuseLogger:
|
|||
}
|
||||
trace = self.Langfuse.trace(**trace_params)
|
||||
|
||||
# Log provider specific information as a span
|
||||
log_provider_specific_information_as_span(trace, clean_metadata)
|
||||
|
||||
generation_id = None
|
||||
usage = None
|
||||
if response_obj is not None and response_obj.get("id", None) is not None:
|
||||
|
@ -632,3 +635,45 @@ def _add_prompt_to_generation_params(
|
|||
generation_params["prompt"] = user_prompt
|
||||
|
||||
return generation_params
|
||||
|
||||
|
||||
def log_provider_specific_information_as_span(
|
||||
trace,
|
||||
clean_metadata,
|
||||
):
|
||||
"""
|
||||
Logs provider-specific information as spans.
|
||||
|
||||
Parameters:
|
||||
trace: The tracing object used to log spans.
|
||||
clean_metadata: A dictionary containing metadata to be logged.
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
from litellm.proxy.proxy_server import premium_user
|
||||
|
||||
_hidden_params = clean_metadata.get("hidden_params", None)
|
||||
vertex_ai_grounding_metadata = _hidden_params.get(
|
||||
"vertex_ai_grounding_metadata", None
|
||||
)
|
||||
|
||||
if vertex_ai_grounding_metadata is not None:
|
||||
if isinstance(vertex_ai_grounding_metadata, list):
|
||||
for elem in vertex_ai_grounding_metadata:
|
||||
if isinstance(elem, dict):
|
||||
for key, value in elem.items():
|
||||
trace.span(
|
||||
name=key,
|
||||
input=value,
|
||||
)
|
||||
else:
|
||||
trace.span(
|
||||
name="vertex_ai_grounding_metadata",
|
||||
input=elem,
|
||||
)
|
||||
else:
|
||||
trace.span(
|
||||
name="vertex_ai_grounding_metadata",
|
||||
input=vertex_ai_grounding_metadata,
|
||||
)
|
||||
|
|
|
@ -37,5 +37,5 @@ general_settings:
|
|||
master_key: sk-1234
|
||||
|
||||
litellm_settings:
|
||||
success_callback: ["prometheus"]
|
||||
success_callback: ["langfuse", "prometheus"]
|
||||
failure_callback: ["prometheus"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue