The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
log provider specific metadata as a span
Ishaan Jaff3e2a1fe0aa2d
diff --git a/litellm/integrations/langfuse.py b/litellm/integrations/langfuse.pyindex 045c8275656..cfbb67be4af 100644--- a/litellm/integrations/langfuse.py+++ b/litellm/integrations/langfuse.py@@ -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 = Noneusage = Noneif 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_promptreturn 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,+ )diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yamlindex 5af3b9360b9..c16d09e72c2 100644--- a/litellm/proxy/proxy_config.yaml+++ b/litellm/proxy/proxy_config.yaml@@ -37,5 +37,5 @@ general_settings:master_key: sk-1234litellm_settings:- success_callback: ["prometheus"]+ success_callback: ["langfuse", "prometheus"]failure_callback: ["prometheus"]