Skip to content

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]

fix: arize nested spans

mubashir1osmani8c2d9e322ce2
diff --git a/litellm/integrations/arize/arize_phoenix.py b/litellm/integrations/arize/arize_phoenix.py
index 4a6e0cec8ca..2e973d12fa6 100644
--- a/litellm/integrations/arize/arize_phoenix.py
+++ b/litellm/integrations/arize/arize_phoenix.py
@@ -35,13 +35,19 @@ class ArizePhoenixLogger(OpenTelemetry):
@staticmethod
def set_arize_phoenix_attributes(span: Span, kwargs, response_obj):
_utils.set_attributes(span, kwargs, response_obj, ArizeOTELAttributes)
+
+ # Set project name on the span for all traces to go to custom Phoenix projects
+ config = ArizePhoenixLogger.get_arize_phoenix_config()
+ if config.project_name:
+ from litellm.integrations.opentelemetry_utils.base_otel_llm_obs_attributes import safe_set_attribute
+ safe_set_attribute(span, "openinference.project.name", config.project_name)
+
return
@staticmethod
def get_arize_phoenix_config() -> ArizePhoenixConfig:
"""
Retrieves the Arize Phoenix configuration based on environment variables.
-
Returns:
ArizePhoenixConfig: A Pydantic model containing Arize Phoenix configuration.
"""
@@ -95,7 +101,7 @@ class ArizePhoenixLogger(OpenTelemetry):
"PHOENIX_API_KEY must be set when using Phoenix Cloud (app.phoenix.arize.com)."
)
- project_name = os.environ.get("PHOENIX_PROJECT_NAME", "litellm-project")
+ project_name = os.environ.get("PHOENIX_PROJECT_NAME", "default")
return ArizePhoenixConfig(
otlp_auth_headers=otlp_auth_headers,
@@ -104,34 +110,6 @@ class ArizePhoenixLogger(OpenTelemetry):
project_name=project_name,
)
- async def async_service_success_hook(
- self,
- payload: ServiceLoggerPayload,
- parent_otel_span: Optional[Span] = None,
- start_time: Optional[Union[datetime, float]] = None,
- end_time: Optional[Union[datetime, float]] = None,
- event_metadata: Optional[dict] = None,
- ):
- pass # suppress additional spans
-
- async def async_service_failure_hook(
- self,
- payload: ServiceLoggerPayload,
- error: Optional[str] = "",
- parent_otel_span: Optional[Span] = None,
- start_time: Optional[Union[datetime, float]] = None,
- end_time: Optional[Union[float, datetime]] = None,
- event_metadata: Optional[dict] = None,
- ):
- pass # suppress additional spans
-
- def create_litellm_proxy_request_started_span(
- self,
- start_time: datetime,
- headers: dict,
- ):
- pass # suppress additional spans
-
async def async_health_check(self):
config = self.get_arize_phoenix_config()
diff --git a/litellm/integrations/opentelemetry.py b/litellm/integrations/opentelemetry.py
index 0d6c0a0c641..93dce578fe1 100644
--- a/litellm/integrations/opentelemetry.py
+++ b/litellm/integrations/opentelemetry.py
@@ -1994,10 +1994,7 @@ class OpenTelemetry(CustomLogger):
"""
Create a span for the received proxy server request.
"""
- # don't create proxy parent spans for arize phoenix - [TODO]: figure out a better way to handle this
- if self.callback_name == "arize_phoenix":
- return None
-
+
return self.tracer.start_span(
name="Received Proxy Server Request",
start_time=self._to_ns(start_time),