mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
use _get_parent_otel_span_from_kwargs
This commit is contained in:
parent
2a89486948
commit
d5d9ed73af
2 changed files with 23 additions and 7 deletions
|
@ -27,12 +27,6 @@ model_list:
|
||||||
mode: audio_speech
|
mode: audio_speech
|
||||||
general_settings:
|
general_settings:
|
||||||
master_key: sk-1234
|
master_key: sk-1234
|
||||||
alerting: ["slack"]
|
|
||||||
alerting_threshold: 0.0001
|
|
||||||
alert_to_webhook_url: {
|
|
||||||
"llm_too_slow": "https://hooks.slack.com/services/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",
|
|
||||||
"llm_requests_hanging": "https://hooks.slack.com/services/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",
|
|
||||||
}
|
|
||||||
|
|
||||||
litellm_settings:
|
litellm_settings:
|
||||||
success_callback: ["langfuse"]
|
callbacks: ["otel"]
|
|
@ -31,6 +31,7 @@ from litellm._service_logger import ServiceLogging, ServiceTypes
|
||||||
from litellm.caching import DualCache, RedisCache
|
from litellm.caching import DualCache, RedisCache
|
||||||
from litellm.exceptions import RejectedRequestError
|
from litellm.exceptions import RejectedRequestError
|
||||||
from litellm.integrations.custom_logger import CustomLogger
|
from litellm.integrations.custom_logger import CustomLogger
|
||||||
|
from litellm.integrations.opentelemetry import _get_parent_otel_span_from_kwargs
|
||||||
from litellm.integrations.slack_alerting import SlackAlerting
|
from litellm.integrations.slack_alerting import SlackAlerting
|
||||||
from litellm.litellm_core_utils.litellm_logging import Logging
|
from litellm.litellm_core_utils.litellm_logging import Logging
|
||||||
from litellm.llms.custom_httpx.httpx_handler import HTTPHandler
|
from litellm.llms.custom_httpx.httpx_handler import HTTPHandler
|
||||||
|
@ -125,6 +126,27 @@ def log_to_opentelemetry(func):
|
||||||
start_time=start_time,
|
start_time=start_time,
|
||||||
end_time=end_time,
|
end_time=end_time,
|
||||||
)
|
)
|
||||||
|
elif (
|
||||||
|
# in litellm custom callbacks kwargs is passed as arg[0]
|
||||||
|
# https://docs.litellm.ai/docs/observability/custom_callback#callback-functions
|
||||||
|
args is not None
|
||||||
|
and len(args) > 0
|
||||||
|
):
|
||||||
|
passed_kwargs = args[0]
|
||||||
|
parent_otel_span = _get_parent_otel_span_from_kwargs(
|
||||||
|
kwargs=passed_kwargs
|
||||||
|
)
|
||||||
|
if parent_otel_span is not None:
|
||||||
|
from litellm.proxy.proxy_server import proxy_logging_obj
|
||||||
|
|
||||||
|
await proxy_logging_obj.service_logging_obj.async_service_success_hook(
|
||||||
|
service=ServiceTypes.DB,
|
||||||
|
call_type=func.__name__,
|
||||||
|
parent_otel_span=parent_otel_span,
|
||||||
|
duration=0.0,
|
||||||
|
start_time=start_time,
|
||||||
|
end_time=end_time,
|
||||||
|
)
|
||||||
# end of logging to otel
|
# end of logging to otel
|
||||||
return result
|
return result
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue