mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-25 01:02:15 +00:00
fix: send list(log_queue) when building request bodies for BoundedQueue
Generic API, Datadog, and Datadog LLM Obs were passing the BoundedQueue object into HTTP/serialization, causing request body to be the queue's string repr. Use list(self.log_queue) so payloads are real lists.
This commit is contained in:
parent
62a1736cc7
commit
730679784e
3 changed files with 7 additions and 6 deletions
|
|
@ -230,7 +230,7 @@ class DataDogLogger(
|
|||
self.intake_url,
|
||||
)
|
||||
|
||||
response = await self.async_send_compressed_data(self.log_queue)
|
||||
response = await self.async_send_compressed_data(list(self.log_queue))
|
||||
if response.status_code == 413:
|
||||
verbose_logger.exception(DD_ERRORS.DATADOG_413_ERROR.value)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -139,14 +139,14 @@ class DataDogLLMObsLogger(CustomBatchLogger[LLMObsPayload]):
|
|||
f"DataDogLLMObs: Flushing {len(self.log_queue)} events"
|
||||
)
|
||||
|
||||
# Prepare the payload
|
||||
# Prepare the payload (use list() so serialization gets a list, not BoundedQueue)
|
||||
payload = {
|
||||
"data": DDIntakePayload(
|
||||
type="span",
|
||||
attributes=DDSpanAttributes(
|
||||
ml_app=get_datadog_service(),
|
||||
tags=[get_datadog_tags()],
|
||||
spans=self.log_queue,
|
||||
spans=list(self.log_queue),
|
||||
),
|
||||
),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,11 +342,12 @@ class GenericAPILogger(CustomBatchLogger[Union[Dict, StandardLoggingPayload]]):
|
|||
f"Generic API Logger - sent log {idx}, status: {result.status_code}" # type: ignore
|
||||
)
|
||||
else:
|
||||
# Format the payload based on log_format
|
||||
# Format the payload based on log_format (use list() so JSON gets a list, not BoundedQueue)
|
||||
batch = list(self.log_queue)
|
||||
if self.log_format == "json_array":
|
||||
data = safe_dumps(self.log_queue)
|
||||
data = safe_dumps(batch)
|
||||
elif self.log_format == "ndjson":
|
||||
data = "\n".join(safe_dumps(log) for log in self.log_queue)
|
||||
data = "\n".join(safe_dumps(log) for log in batch)
|
||||
else:
|
||||
raise ValueError(f"Unknown log_format: {self.log_format}")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue