diff --git a/litellm/integrations/opentelemetry.py b/litellm/integrations/opentelemetry.py index 3fc50848e..5d308dc37 100644 --- a/litellm/integrations/opentelemetry.py +++ b/litellm/integrations/opentelemetry.py @@ -162,7 +162,8 @@ class OpenTelemetry(CustomLogger): proxy_server_request = litellm_params.get("proxy_server_request", {}) or {} headers = proxy_server_request.get("headers", {}) or {} traceparent = headers.get("traceparent", None) - parent_otel_span = litellm_params.get("litellm_parent_otel_span", None) + _metadata = litellm_params.get("metadata", {}) + parent_otel_span = _metadata.get("litellm_parent_otel_span", None) """ Two way to use parents in opentelemetry diff --git a/litellm/main.py b/litellm/main.py index 596f85f33..f76d6c521 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -600,7 +600,6 @@ def completion( client = kwargs.get("client", None) ### Admin Controls ### no_log = kwargs.get("no-log", False) - litellm_parent_otel_span = kwargs.get("litellm_parent_otel_span", None) ######## end of unpacking kwargs ########### openai_params = [ "functions", @@ -690,7 +689,6 @@ def completion( "allowed_model_region", "model_config", "fastest_response", - "litellm_parent_otel_span", ] default_params = openai_params + litellm_params @@ -875,7 +873,6 @@ def completion( input_cost_per_token=input_cost_per_token, output_cost_per_second=output_cost_per_second, output_cost_per_token=output_cost_per_token, - litellm_parent_otel_span=litellm_parent_otel_span, ) logging.update_environment_variables( model=model, diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.py index 1614a6dfe..945799b4c 100644 --- a/litellm/proxy/litellm_pre_call_utils.py +++ b/litellm/proxy/litellm_pre_call_utils.py @@ -106,7 +106,7 @@ async def add_litellm_data_to_request( data["metadata"]["headers"] = _headers data["metadata"]["endpoint"] = str(request.url) # Add the OTEL Parent Trace before sending it LiteLLM - data["litellm_parent_otel_span"] = user_api_key_dict.parent_otel_span + data["metadata"]["litellm_parent_otel_span"] = user_api_key_dict.parent_otel_span ### END-USER SPECIFIC PARAMS ### if user_api_key_dict.allowed_model_region is not None: diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 8ae811f11..f3bbf69c4 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -73,7 +73,8 @@ def print_verbose(print_statement): def safe_deep_copy(data): if isinstance(data, dict): # remove litellm_parent_otel_span since this is not picklable - data.pop("litellm_parent_otel_span", None) + if "metadata" in data and "litellm_parent_otel_span" in data["metadata"]: + data["metadata"].pop("litellm_parent_otel_span") new_data = copy.deepcopy(data) return new_data diff --git a/litellm/tests/test_proxy_server.py b/litellm/tests/test_proxy_server.py index 6e6012199..114b96872 100644 --- a/litellm/tests/test_proxy_server.py +++ b/litellm/tests/test_proxy_server.py @@ -152,7 +152,6 @@ def test_chat_completion(mock_acompletion, client_no_auth): specific_deployment=True, metadata=mock.ANY, proxy_server_request=mock.ANY, - litellm_parent_otel_span=mock.ANY, ) print(f"response - {response.text}") assert response.status_code == 200 diff --git a/litellm/utils.py b/litellm/utils.py index be7728dfe..822fea481 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -4918,7 +4918,6 @@ def get_litellm_params( input_cost_per_token=None, output_cost_per_token=None, output_cost_per_second=None, - litellm_parent_otel_span=None, ): litellm_params = { "acompletion": acompletion, @@ -4941,7 +4940,6 @@ def get_litellm_params( "input_cost_per_second": input_cost_per_second, "output_cost_per_token": output_cost_per_token, "output_cost_per_second": output_cost_per_second, - "litellm_parent_otel_span": litellm_parent_otel_span, } return litellm_params