Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix dd llm obs] - use env vars for setting dd tags, service name #7835

Merged
merged 2 commits into from
Jan 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions litellm/integrations/datadog/datadog_llm_obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import litellm
from litellm._logging import verbose_logger
from litellm.integrations.custom_batch_logger import CustomBatchLogger
from litellm.integrations.datadog.datadog import DataDogLogger
from litellm.llms.custom_httpx.http_handler import (
get_async_httpx_client,
httpxSpecialProvider,
Expand All @@ -24,7 +25,7 @@
from litellm.types.utils import StandardLoggingPayload


class DataDogLLMObsLogger(CustomBatchLogger):
class DataDogLLMObsLogger(DataDogLogger, CustomBatchLogger):
def __init__(self, **kwargs):
try:
verbose_logger.debug("DataDogLLMObs: Initializing logger")
Expand Down Expand Up @@ -52,7 +53,7 @@ def __init__(self, **kwargs):
asyncio.create_task(self.periodic_flush())
self.flush_lock = asyncio.Lock()
self.log_queue: List[LLMObsPayload] = []
super().__init__(**kwargs, flush_lock=self.flush_lock)
CustomBatchLogger.__init__(self, **kwargs, flush_lock=self.flush_lock)
except Exception as e:
verbose_logger.exception(f"DataDogLLMObs: Error initializing - {str(e)}")
raise e
Expand Down Expand Up @@ -89,16 +90,13 @@ async def async_send_batch(self):
"data": DDIntakePayload(
type="span",
attributes=DDSpanAttributes(
ml_app="litellm",
tags=[
"service:litellm",
f"env:{os.getenv('DD_ENV', 'production')}",
],
ml_app=self._get_datadog_service(),
tags=[self._get_datadog_tags()],
spans=self.log_queue,
),
),
}
verbose_logger.debug("payload", json.dumps(payload, indent=4))
verbose_logger.debug("payload %s", json.dumps(payload, indent=4))
response = await self.async_client.post(
url=self.intake_url,
json=payload,
Expand Down
Loading