From 0dc7d538b5db946aa92a2647d93f05af404dc3ae Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Fri, 8 Dec 2023 18:39:52 -0800 Subject: [PATCH] (docs) proxy - OTEL + traceloop --- docs/my-website/docs/proxy/logging.md | 81 ++++++++++++++------------- litellm/proxy/proxy_server.py | 4 ++ 2 files changed, 46 insertions(+), 39 deletions(-) diff --git a/docs/my-website/docs/proxy/logging.md b/docs/my-website/docs/proxy/logging.md index 1c883a931d..f5e54351b4 100644 --- a/docs/my-website/docs/proxy/logging.md +++ b/docs/my-website/docs/proxy/logging.md @@ -284,9 +284,47 @@ ModelResponse( ``` -## OpenTelemetry, ElasticSearch +## OpenTelemetry - Traceloop -### Step 1 Start OpenTelemetry Collecter Docker Container +Traceloop allows you to log LLM Input/Output in the OpenTelemetry format + +We will use the `--config` to set `litellm.success_callback = ["traceloop"]` this will log all successfull LLM calls to traceloop + +**Step 1** Install traceloop-sdk and set Traceloop API key + +```shell +pip install traceloop-sdk -U +``` + +```shell +TRACELOOP_API_KEY=51e7164.. +``` + +**Step 2**: Create a `config.yaml` file and set `litellm_settings`: `success_callback` +```yaml +model_list: + - model_name: gpt-3.5-turbo + litellm_params: + model: gpt-3.5-turbo +litellm_settings: + success_callback: ["traceloop"] +``` + +**Step 3**: Start the proxy, make a test request + +Start proxy +```shell +litellm --config config.yaml --debug +``` + +Test Request +``` +litellm --test +``` + + + + ## Logging Proxy Input/Output - Langfuse We will use the `--config` to set `litellm.success_callback = ["langfuse"]` this will log all successfull LLM calls to langfuse diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 3ff097b5e5..8a4e12c802 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -523,6 +523,10 @@ def load_router_config(router: Optional[litellm.Router], config_file_path: str): # these are litellm callbacks - "langfuse", "sentry", "wandb" else: litellm.success_callback.append(callback) + if callback == "traceloop": + from traceloop.sdk import Traceloop + print_verbose(f"{blue_color_code} Initializing Traceloop SDK - \nRunning:`Traceloop.init(app_name='Litellm-Server', disable_batch=True)`") + Traceloop.init(app_name="Litellm-Server", disable_batch=True) print_verbose(f"{blue_color_code} Initialized Success Callbacks - {litellm.success_callback} {reset_color_code}") elif key == "failure_callback": litellm.failure_callback = []