{"record":{"id":"ab7429b91d75cbcf","repo":"BerriAI/litellm","slug":"response-from-datadog-api-status-code-response-s","errorCode":null,"errorMessage":"Response from datadog API status_code: {response.status_code}, text: {response.text}","messagePattern":"Response from datadog API status_code: (.+?), text: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"litellm/integrations/datadog/datadog.py","lineNumber":509,"sourceCode":"                    start_time=start_time,\n                    end_time=end_time,\n                )\n\n            # Build headers\n            headers: Final = {}\n            # Add API key if available (required for direct API, optional for agent)\n            if self.DD_API_KEY:\n                headers[\"DD-API-KEY\"] = self.DD_API_KEY\n\n            response: Final = self.sync_client.post(\n                url=self.intake_url,\n                json=dd_payload,\n                headers=headers,\n            )\n\n            response.raise_for_status()\n            if response.status_code != 202:\n                raise Exception(f\"Response from datadog API status_code: {response.status_code}, text: {response.text}\")\n\n            verbose_logger.debug(\n                \"Datadog: Response from datadog API status_code: %s, text: %s\",\n                response.status_code,\n                response.text,\n            )\n\n        except Exception as e:\n            verbose_logger.exception(\"Datadog Layer Error - %s\\n%s\", e, traceback.format_exc())\n\n    async def _log_async_event(self, kwargs, response_obj, start_time, end_time):\n        dd_payload: Final = self.create_datadog_logging_payload(\n            kwargs=kwargs,\n            response_obj=response_obj,\n            start_time=start_time,\n            end_time=end_time,\n        )\n","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/datadog/datadog.py#L491-L527","documentation":"After POSTing a batch of log payloads to the Datadog logs intake, the logger expects HTTP 202 (Accepted). Any other status — after raise_for_status() already let non-2xx through as an exception path — produces this Exception carrying the status code and response text. The surrounding except swallows and logs it, so the practical effect is dropped telemetry plus an error log, not a crash of the LLM call.","triggerScenarios":"Datadog intake returns non-202 for the batch: 403 Forbidden (wrong/revoked API key), 400 (malformed payload or wrong site), 404 (site mismatch, e.g. DD_SITE=us5 but key belongs to another region), or 429 rate limiting.","commonSituations":"DD_SITE set to the wrong region for the org; API key rotated in Datadog but not in the proxy env; large bursts exceeding intake limits; clock/payload schema drift after upgrading litellm's Datadog serializer.","solutions":["Check verbose_logger output for the exact status/text pair: 403 -> fix DD_API_KEY, 404/400 -> fix DD_SITE, 429 -> batch/rate limits","Verify the key/site pair by curling the intake directly with a minimal payload","Rotate or re-issue the API key in Datadog and update the proxy environment, then restart"],"exampleFix":"# before\nDD_SITE=datadoghq.com   # generic site, org is on us5\n\n# after\nDD_SITE=us5.datadoghq.com","handlingStrategy":"try-catch","validationCode":"import httpx, os\n\ndef intake_ok() -> bool:\n    r = httpx.post(\n        f\"https://http-intake.logs.{os.getenv('DD_SITE')}/api/v2/logs\",\n        headers={\"DD-API-KEY\": os.environ[\"DD_API_KEY\"]},\n        json=[{\"message\": \"smoke\"}],\n    )\n    return r.status_code == 202","typeGuard":null,"tryCatchPattern":"# litellm already swallows and logs this; monitor for it instead:\n# grep 'Datadog Layer Error' in proxy logs and alert on repeats;\n# 403 -> key, 404/400 -> site, 429 -> throughput","preventionTips":["Alert on repeated 'Datadog Layer Error' log lines — logs are silently dropped otherwise","Smoke-test the key/site pair with a curl POST before deploying","Rotate Datadog keys on a schedule and update the proxy env in the same change"],"tags":["datadog","logging","http","batching"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}