Skip to content

Commit 5238700

Browse files
committed
fix(openai-v2): accept APITimeoutError in bad-endpoint tests for Windows
On Windows, connecting to localhost:4242 with timeout=0.1s raises APITimeoutError (TCP SYN retries) instead of APIConnectionError (immediate ECONNREFUSED on Unix). Both indicate unreachable endpoint. Made-with: Cursor
1 parent d5536eb commit 5238700

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/test_async_chat_completions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ async def test_async_chat_completion_bad_endpoint(
128128
spans[0], llm_model_value, server_address="localhost"
129129
)
130130
assert 4242 == spans[0].attributes[ServerAttributes.SERVER_PORT]
131-
assert (
132-
"APIConnectionError" == spans[0].attributes[ErrorAttributes.ERROR_TYPE]
131+
assert spans[0].attributes[ErrorAttributes.ERROR_TYPE] in (
132+
"APIConnectionError",
133+
"APITimeoutError",
133134
)
134135

135136

instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/test_chat_completions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,9 @@ def test_chat_completion_bad_endpoint(
176176
spans[0], llm_model_value, server_address="localhost"
177177
)
178178
assert 4242 == spans[0].attributes[ServerAttributes.SERVER_PORT]
179-
assert (
180-
"APIConnectionError" == spans[0].attributes[ErrorAttributes.ERROR_TYPE]
179+
assert spans[0].attributes[ErrorAttributes.ERROR_TYPE] in (
180+
"APIConnectionError",
181+
"APITimeoutError",
181182
)
182183

183184
metrics = metric_reader.get_metrics_data().resource_metrics

instrumentation-genai/opentelemetry-instrumentation-openai-v2/tests/test_embeddings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,9 @@ def test_embeddings_bad_endpoint(
214214
server_address="localhost",
215215
)
216216
assert 4242 == spans[0].attributes[ServerAttributes.SERVER_PORT]
217-
assert (
218-
"APIConnectionError" == spans[0].attributes[ErrorAttributes.ERROR_TYPE]
217+
assert spans[0].attributes[ErrorAttributes.ERROR_TYPE] in (
218+
"APIConnectionError",
219+
"APITimeoutError",
219220
)
220221

221222
# Verify metrics

0 commit comments

Comments
 (0)