{"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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/datadog/datadog.py#L491-L527","documentation":"DatadogLogger's synchronous event logging POSTs the logging payload to the Datadog logs intake endpoint and expects HTTP 202 Accepted. response.raise_for_status() runs first, so true 4xx/5xx replies surface as httpx.HTTPStatusError; this generic Exception fires only when the server answers 2xx but not 202. The whole handler is wrapped in `except Exception` and logged via verbose_logger.exception, so it never propagates to the caller — the log event is simply lost.","triggerScenarios":"Datadog callback enabled in direct-API mode and the intake URL does not point at the real logs intake (e.g. DD_BASE_URL override pointing at a generic Datadog API endpoint that answers 200), an intermediate proxy/gateway that returns its own 2xx, or an agent forwarder that replies with a non-202 success code.","commonSituations":"Setting DD_BASE_URL to a wrong host while also setting DD_API_KEY (so the env checks pass), routing traffic through a corporate proxy that swallows the response, or a Datadog-side API change. Bad API keys usually manifest as HTTPStatusError from raise_for_status instead of this message.","solutions":["Enable verbose logging (litellm.set_verbose=True or LITELLM_LOG=DEBUG) and read the logged status_code and response text for the exact rejection reason","Check for a DD_BASE_URL override and either unset it or point it at the correct logs intake for your DD_SITE (https://http-intake.logs.<DD_SITE>)","Verify the API key by curl-ing the intake endpoint directly with a tiny payload and confirming a 202","If a proxy sits in front, confirm it forwards the request and passes Datadog's 202 back untouched"],"exampleFix":"# before\nexport DD_BASE_URL=https://api.us5.datadoghq.com   # wrong: generic API host answers non-202\n\n# after\nunset DD_BASE_URL                                    # use default intake for DD_SITE\nexport DD_SITE=us5.datadoghq.com\nexport DD_API_KEY=<key>\ncurl -s -o /dev/null -w '%{http_code}' -X POST \"https://http-intake.logs.us5.datadoghq.com/api/v2/logs\" -H \"DD-API-KEY: $DD_API_KEY\" -H 'Content-Type: application/json' -d '[{\"message\":\"ping\"}]'  # expect 202","handlingStrategy":"validation","validationCode":"import os, httpx\n\ndef datadog_intake_reachable() -> bool:\n    \"\"\"Pre-flight: logs intake must answer 202 to a tiny POST before enabling the callback.\"\"\"\n    site = os.getenv(\"DD_SITE\", \"datadoghq.com\")\n    key = os.getenv(\"DD_API_KEY\")\n    if not key:\n        return False\n    base = os.getenv(\"DD_BASE_URL\") or f\"https://http-intake.logs.{site}\"\n    r = httpx.post(f\"{base}/api/v2/logs\", headers={\"DD-API-KEY\": key}, json=[{\"message\": \"preflight\"}])\n    return r.status_code == 202","typeGuard":null,"tryCatchPattern":"// Raised inside litellm's callback and already logged; no caller-side catch applies.\n// Monitor verbose logs for 'Datadog Layer Error' instead of catching.","preventionTips":["Run the intake pre-flight check in CI before deploying with the datadog callback","Never point DD_BASE_URL at a generic API host; verify the URL answers 202 to a test POST","Alert on repeated 'Datadog Layer Error' log lines to catch silent telemetry loss"],"tags":["datadog","logging","http-status","telemetry-loss","integration"],"backgroundTag":"unexpected-http-status-code","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}