From ca97194a0e8f4e5064c276aa21008a8d6972296e Mon Sep 17 00:00:00 2001 From: Jeong Hasang Date: Thu, 11 Jun 2026 16:46:31 +0900 Subject: [PATCH 1/2] fix(llmobs): respect configured writer timeout in _send_payload BaseLLMObsWriter._send_payload called get_connection(self._intake) without a timeout, so it ignored the writer's configured self._timeout (_DD_LLMOBS_WRITER_TIMEOUT, default 5s) and fell back to the 2s connection default (DEFAULT_TIMEOUT). On high-latency links the 2s socket timeout was exceeded at the tail, all retries hit the same ceiling, and the payload was dropped. Every other get_connection call in the module passes timeout= explicitly; this was the only one that did not. Pass timeout=self._timeout to match sibling code. Co-Authored-By: Claude Opus 4.8 (1M context) --- ddtrace/llmobs/_writer.py | 2 +- ...mobs-writer-respect-timeout-cd84c70e0d69e371.yaml | 7 +++++++ tests/llmobs/test_llmobs_span_agentless_writer.py | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-llmobs-writer-respect-timeout-cd84c70e0d69e371.yaml diff --git a/ddtrace/llmobs/_writer.py b/ddtrace/llmobs/_writer.py index 08b27451ffd..8678932d35f 100644 --- a/ddtrace/llmobs/_writer.py +++ b/ddtrace/llmobs/_writer.py @@ -304,7 +304,7 @@ def periodic(self) -> None: ) def _send_payload(self, payload: bytes, num_events: int): - conn = get_connection(self._intake) + conn = get_connection(self._intake, timeout=self._timeout) try: conn.request("POST", self._endpoint, payload, self._headers) resp = conn.getresponse() diff --git a/releasenotes/notes/fix-llmobs-writer-respect-timeout-cd84c70e0d69e371.yaml b/releasenotes/notes/fix-llmobs-writer-respect-timeout-cd84c70e0d69e371.yaml new file mode 100644 index 00000000000..adb1463c6f7 --- /dev/null +++ b/releasenotes/notes/fix-llmobs-writer-respect-timeout-cd84c70e0d69e371.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + LLM Observability: Resolves an issue where the writer ignored its configured request + timeout (``_DD_LLMOBS_WRITER_TIMEOUT``, default 5 seconds) and instead used the 2 second + connection default, causing intermittent ``TimeoutError`` and dropped span and evaluation + metric events on high-latency connections to the agent or intake. diff --git a/tests/llmobs/test_llmobs_span_agentless_writer.py b/tests/llmobs/test_llmobs_span_agentless_writer.py index cf2269e3baa..a94049399f6 100644 --- a/tests/llmobs/test_llmobs_span_agentless_writer.py +++ b/tests/llmobs/test_llmobs_span_agentless_writer.py @@ -136,6 +136,18 @@ def log_message(self, *args): ) +@mock.patch("ddtrace.llmobs._writer.get_connection") +def test_send_payload_uses_configured_timeout(mock_get_connection, mock_writer_logs): + """Regression: _send_payload must open the connection with the writer's configured + timeout (self._timeout), not get_connection's DEFAULT_TIMEOUT (2.0s). + """ + mock_get_connection.return_value.getresponse.return_value.status = 200 + llmobs_span_writer = LLMObsSpanWriter(1, 5.0, is_agentless=True, _site=DD_SITE, _api_key=DD_API_KEY) + llmobs_span_writer.enqueue(_completion_event()) + llmobs_span_writer.periodic() + mock_get_connection.assert_called_once_with(llmobs_span_writer._intake, timeout=5.0) + + def test_send_completion_no_api_key(mock_writer_logs): with override_global_config(dict(_dd_api_key="")): llmobs_span_writer = LLMObsSpanWriter(interval=1, timeout=1, is_agentless=True, _site=DD_SITE, _api_key="") From 192d87d31bd15f4057a6572319f929714ae9491a Mon Sep 17 00:00:00 2001 From: Jeong Hasang Date: Thu, 11 Jun 2026 17:07:02 +0900 Subject: [PATCH 2/2] docs(llmobs): align release note wording with convention Co-Authored-By: Claude Opus 4.8 (1M context) --- .../fix-llmobs-writer-respect-timeout-cd84c70e0d69e371.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/fix-llmobs-writer-respect-timeout-cd84c70e0d69e371.yaml b/releasenotes/notes/fix-llmobs-writer-respect-timeout-cd84c70e0d69e371.yaml index adb1463c6f7..980d35b9e22 100644 --- a/releasenotes/notes/fix-llmobs-writer-respect-timeout-cd84c70e0d69e371.yaml +++ b/releasenotes/notes/fix-llmobs-writer-respect-timeout-cd84c70e0d69e371.yaml @@ -1,7 +1,7 @@ --- fixes: - | - LLM Observability: Resolves an issue where the writer ignored its configured request + LLM Observability: Fixes an issue where the writer ignored its configured request timeout (``_DD_LLMOBS_WRITER_TIMEOUT``, default 5 seconds) and instead used the 2 second connection default, causing intermittent ``TimeoutError`` and dropped span and evaluation metric events on high-latency connections to the agent or intake.