mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
forward otel traceparent in request headers
This commit is contained in:
parent
7505a4be02
commit
0368c89dd8
2 changed files with 20 additions and 0 deletions
|
@ -144,10 +144,13 @@ async def add_litellm_data_to_request(
|
||||||
) # do not store the original `sk-..` api key in the db
|
) # do not store the original `sk-..` api key in the db
|
||||||
data[_metadata_variable_name]["headers"] = _headers
|
data[_metadata_variable_name]["headers"] = _headers
|
||||||
data[_metadata_variable_name]["endpoint"] = str(request.url)
|
data[_metadata_variable_name]["endpoint"] = str(request.url)
|
||||||
|
|
||||||
|
# OTEL Controls / Tracing
|
||||||
# Add the OTEL Parent Trace before sending it LiteLLM
|
# Add the OTEL Parent Trace before sending it LiteLLM
|
||||||
data[_metadata_variable_name][
|
data[_metadata_variable_name][
|
||||||
"litellm_parent_otel_span"
|
"litellm_parent_otel_span"
|
||||||
] = user_api_key_dict.parent_otel_span
|
] = user_api_key_dict.parent_otel_span
|
||||||
|
_add_otel_traceparent_to_data(data, request=request)
|
||||||
|
|
||||||
### END-USER SPECIFIC PARAMS ###
|
### END-USER SPECIFIC PARAMS ###
|
||||||
if user_api_key_dict.allowed_model_region is not None:
|
if user_api_key_dict.allowed_model_region is not None:
|
||||||
|
@ -169,3 +172,18 @@ async def add_litellm_data_to_request(
|
||||||
} # add the team-specific configs to the completion call
|
} # add the team-specific configs to the completion call
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def _add_otel_traceparent_to_data(data: dict, request: Request):
|
||||||
|
if data is None:
|
||||||
|
return
|
||||||
|
if request.headers:
|
||||||
|
if "traceparent" in request.headers:
|
||||||
|
# we want to forward this to the LLM Provider
|
||||||
|
# Relevant issue: https://github.com/BerriAI/litellm/issues/4419
|
||||||
|
# pass this in extra_headers
|
||||||
|
if "extra_headers" not in data:
|
||||||
|
data["extra_headers"] = {}
|
||||||
|
_exra_headers = data["extra_headers"]
|
||||||
|
if "traceparent" not in _exra_headers:
|
||||||
|
_exra_headers["traceparent"] = request.headers["traceparent"]
|
||||||
|
|
|
@ -3670,6 +3670,8 @@ def get_supported_openai_params(
|
||||||
"tool_choice",
|
"tool_choice",
|
||||||
"response_format",
|
"response_format",
|
||||||
"seed",
|
"seed",
|
||||||
|
"extra_headers",
|
||||||
|
"extra_body",
|
||||||
]
|
]
|
||||||
elif custom_llm_provider == "deepseek":
|
elif custom_llm_provider == "deepseek":
|
||||||
return [
|
return [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue