{"record":{"id":"b0177f3b7bea839e","repo":"BerriAI/litellm","slug":"datadogllmobs-standard-logging-object-is-not-set","errorCode":null,"errorMessage":"DataDogLLMObs: standard_logging_object is not set","messagePattern":"DataDogLLMObs: standard_logging_object is not set","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/datadog/datadog_llm_obs.py","lineNumber":222,"sourceCode":"            if response.status_code != 202:\n                raise Exception(\n                    f\"DataDogLLMObs: Unexpected response - status_code: {response.status_code}, text: {response.text}\"\n                )\n\n            if self.is_mock_mode:\n                verbose_logger.debug(\"[DATADOG MOCK] Batch of %s events successfully mocked\", len(self.log_queue))\n            else:\n                verbose_logger.debug(\"DataDogLLMObs: Successfully sent batch - status_code: %s\", response.status_code)\n            self.log_queue.clear()\n        except httpx.HTTPStatusError as e:\n            verbose_logger.exception(\"DataDogLLMObs: Error sending batch - %s\", e.response.text)\n        except Exception as e:\n            verbose_logger.exception(\"DataDogLLMObs: Error sending batch - %s\", e)\n\n    def create_llm_obs_payload(self, kwargs: dict, start_time: datetime, end_time: datetime) -> LLMObsPayload:\n        standard_logging_payload: Final[StandardLoggingPayload | None] = kwargs.get(\"standard_logging_object\")\n        if standard_logging_payload is None:\n            raise Exception(\"DataDogLLMObs: standard_logging_object is not set\")\n\n        messages = standard_logging_payload[\"messages\"]\n        messages = self._ensure_string_content(messages=messages)\n\n        metadata: Final = kwargs.get(\"litellm_params\", {}).get(\"metadata\", {})\n\n        input_meta: Final = InputMeta(messages=handle_any_messages_to_chat_completion_str_messages_conversion(messages))\n        output_meta: Final = OutputMeta(\n            messages=self._get_response_messages(\n                standard_logging_payload=standard_logging_payload,\n                call_type=standard_logging_payload.get(\"call_type\"),\n            )\n        )\n\n        error_info: Final = self._assemble_error_info(standard_logging_payload)\n\n        metadata_parent_id: str | None = None\n        if isinstance(metadata, dict):","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/datadog/datadog_llm_obs.py#L204-L240","documentation":"create_llm_obs_payload reads kwargs[\"standard_logging_object\"] — the StandardLoggingPayload that litellm's core attaches during real logging hooks — and raises a plain Exception when it is missing. All callers in this class (async_log_success_event / async_log_failure_event) wrap payload creation in try/except and log the exception, so the visible symptom is an error line plus lost telemetry for that call, not a crash.","triggerScenarios":"Invoking create_llm_obs_payload directly (tests, custom orchestration) with kwargs lacking the key; manually calling async_log_success_event with fabricated kwargs; version skew between the integration and a litellm core that no longer populates the object.","commonSituations":"Unit tests for the datadog LLM-obs integration that build kwargs by hand; forks pinning an old litellm core with a new integrations package.","solutions":["Drive the integration through a real litellm.completion call with the callback attached so standard_logging_object is populated","If calling directly, attach a StandardLoggingPayload to kwargs first (build one with litellm's get_standard_logging_payload helpers)","Align litellm package versions (single install) so the hook contract holds"],"exampleFix":"# before\ndef test_payload():\n    kwargs = {\"model\": \"gpt-4\"}\n    logger.create_llm_obs_payload(kwargs, start, end)  # Exception\n\n# after\ndef test_payload(standard_logging_payload):\n    kwargs = {\"model\": \"gpt-4\", \"standard_logging_object\": standard_logging_payload}\n    logger.create_llm_obs_payload(kwargs, start, end)","handlingStrategy":"validation","validationCode":"def safe_create_llm_obs_payload(logger, kwargs, start, end):\n    if kwargs.get(\"standard_logging_object\") is None:\n        return None  # skip rather than raise\n    return logger.create_llm_obs_payload(kwargs, start, end)","typeGuard":"from typing import Any\n\ndef has_slo(kwargs: Any) -> bool:\n    \"\"\"True when kwargs came from litellm's real logging hooks.\"\"\"\n    return isinstance(kwargs, dict) and isinstance(kwargs.get(\"standard_logging_object\"), dict)","tryCatchPattern":"try:\n    payload = logger.create_llm_obs_payload(kwargs, start_time, end_time)\nexcept Exception as e:  # callers in this class do exactly this; mirror it in custom code\n    litellm.verbose_logger.exception(\"llm-obs payload skipped: %s\", e)\n    payload = None","preventionTips":["Only invoke logging hooks with kwargs captured from litellm hooks","Record a real StandardLoggingPayload fixture once and reuse it in tests","Upgrade litellm wholesale rather than mixing integration and core versions"],"tags":["datadog","llm-obs","kwargs","internal-api","misuse"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}