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: req changes

Harshit Jaincd60e3d4e0ad
diff --git a/docs/my-website/docs/observability/datadog.md b/docs/my-website/docs/observability/datadog.md
index ef48594cbfa..e83cfcbafe0 100644
--- a/docs/my-website/docs/observability/datadog.md
+++ b/docs/my-website/docs/observability/datadog.md
@@ -193,7 +193,7 @@ All metrics include the following tags: `env`, `service`, `version`, `HOSTNAME`,
```yaml
model_list:
- - model_name: gpt-3.5-turbo
+ - model_name: gpt-3.5-turbo
litellm_params:
model: gpt-3.5-turbo
litellm_settings:
diff --git a/litellm/integrations/datadog/datadog_metrics.py b/litellm/integrations/datadog/datadog_metrics.py
index ca3e4aa5a1f..43dd0662604 100644
--- a/litellm/integrations/datadog/datadog_metrics.py
+++ b/litellm/integrations/datadog/datadog_metrics.py
@@ -1,4 +1,5 @@
import asyncio
+import gzip
import os
import time
from datetime import datetime
@@ -6,6 +7,7 @@ from typing import List, Optional, Union
from litellm._logging import verbose_logger
from litellm.integrations.custom_batch_logger import CustomBatchLogger
+from litellm.litellm_core_utils.safe_json_dumps import safe_dumps
from litellm.llms.custom_httpx.http_handler import (
get_async_httpx_client,
httpxSpecialProvider,
@@ -39,8 +41,9 @@ class DatadogMetricsLogger(CustomBatchLogger):
# Initialize lock
self.flush_lock = asyncio.Lock()
- # Check if flush_lock is already in kwargs to avoid double passing
- kwargs["flush_lock"] = self.flush_lock
+ # Only set flush_lock if not already provided by caller
+ if "flush_lock" not in kwargs:
+ kwargs["flush_lock"] = self.flush_lock
# Send metrics more quickly to datadog (every 5 seconds)
if "flush_interval" not in kwargs:
@@ -230,10 +233,6 @@ class DatadogMetricsLogger(CustomBatchLogger):
if self.dd_app_key:
headers["DD-APPLICATION-KEY"] = self.dd_app_key
- import gzip
-
- from litellm.litellm_core_utils.safe_json_dumps import safe_dumps
-
json_data = safe_dumps(payload)
compressed_data = gzip.compress(json_data.encode("utf-8"))
headers["Content-Encoding"] = "gzip"