Skip to content

feat(openai): extend version range to support openai v3 - #393

Merged
lmolkova merged 11 commits into
mainfrom
copilot/support-openai-v3
Aug 19, 2026
Merged

feat(openai): extend version range to support openai v3#393
lmolkova merged 11 commits into
mainfrom
copilot/support-openai-v3

Conversation

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

openai v3 ships httpx2 instead of httpx as its HTTP transport. The instrumentation hard-imported httpx directly, which broke on import with openai v3 installed.

Changes

  • pyproject.toml — Extend instruments extra upper bound: openai >= 1.26.0, < 4
  • utils.py / _raw_response.py — Conditional import: try httpx, fall back to httpx2
    try:
        from httpx import URL
    except ImportError:
        from httpx2 import URL
  • tests/requirements.latest.txt — Pin openai==3.1.0, replace httpx==0.28.1httpx2==2.7.0, drop opentelemetry-instrumentation-httpx (irrelevant for v3)
  • test_raw_response_httpx_interop.py — Replace bare import httpx with pytest.importorskip("httpx") so the module auto-skips under v3 (the httpx instrumentation interop test only applies when openai uses httpx)
  • test_embedding_invocation_unit.py — Same conditional URL import as production code

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

Full test suite run against openai 3.1.0: 249 passed, 1 skipped (httpx interop module, expected).

  • Test A

Checklist

  • Followed the style guidelines of this project
  • Changelog updated if the change requires an entry
  • Unit tests added
  • Documentation updated

Copilot AI linked an issue Aug 15, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Extend version range to support OpenAI v3 feat(openai): extend version range to support openai v3 Aug 15, 2026
Copilot AI requested a review from lmolkova August 15, 2026 16:22

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

@lmolkova I've opened a new pull request, #395, to work on those changes. Once the pull request is ready, I'll request review from you.

@lmolkova

Copy link
Copy Markdown
Member

@lmolkova I've opened a new pull request, #395, to work on those changes. Once the pull request is ready, I'll request review from you.

@copilot the ask was to add to this pr, not open the new one

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

@lmolkova I've opened a new pull request, #395, to work on those changes. Once the pull request is ready, I'll request review from you.

@copilot the ask was to add to this pr, not open the new on...

Added to this PR. get_server_address_and_port now uses getattr(base_url, "host", None) / getattr(base_url, "port", None) instead of isinstance(URL), so it works with httpx.URL, httpx2.URL, and any future URL type. The httpx/httpx2 import is also removed from utils.py since it was only needed for the type check. A regression test is included. Changelog fragment at .changelog/393.fixed.

@lmolkova
lmolkova marked this pull request as ready for review August 15, 2026 16:56
@lmolkova
lmolkova requested a review from a team as a code owner August 15, 2026 16:56
Copilot AI lite review requested due to automatic review settings August 15, 2026 16:56
Copilot AI requested a review from lmolkova August 15, 2026 16:56
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 15, 2026

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-08-19 23:18 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@lmolkova
lmolkova force-pushed the copilot/support-openai-v3 branch 2 times, most recently from 2cbd6bd to 818ec19 Compare August 19, 2026 13:04
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 19, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@lmolkova
lmolkova force-pushed the copilot/support-openai-v3 branch from 818ec19 to 97b128e Compare August 19, 2026 13:05
Extend the supported version range for the openai library to include v3.

openai v3 switched from httpx to httpx2 as its HTTP client library.
Update the instrumentation to import URL and the HTTP response type from
httpx with a fallback to httpx2, so both v1/v2 and v3 are supported.

The httpx interop test is skipped when httpx is not installed (openai v3),
since that test specifically exercises opentelemetry-instrumentation-httpx
which only applies to the httpx transport used by openai v1/v2.

Assisted-by: Claude Sonnet 4.6
…test

Instead of a dedicated pytest.importorskip("httpx"), move import httpx after
the existing pytest.importorskip("opentelemetry.instrumentation.httpx"). Since
the httpx instrumentation depends on httpx, the existing importorskip already
handles graceful skipping when httpx is absent (e.g. openai v3+).

Assisted-by: Claude Sonnet 4.6
…nai v3

Use getattr-based host/port extraction instead of isinstance(URL) so
server.address and server.port are recorded with any URL implementation
(httpx.URL, httpx2.URL, or future types). This also removes the now-unused
httpx/httpx2 URL import from utils.py.

Adds a regression test verifying server.address is populated for a
non-httpx URL (simulating httpx2.URL via SimpleNamespace).

Fixes: server.address/server.port silently absent on openai v3+.

Assisted-by: Claude Sonnet 4.6
Adds a requirements.latest2.txt pinned to openai 2.54.0 + httpx 0.28.1
and a corresponding tox factor so the httpx interop tests continue to
run under CI alongside the openai v3 (httpx2) latest factor.
@lmolkova
lmolkova force-pushed the copilot/support-openai-v3 branch from 97b128e to 4e07915 Compare August 19, 2026 13:27
@lmolkova
lmolkova enabled auto-merge August 19, 2026 13:30
@lmolkova
lmolkova added this pull request to the merge queue Aug 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Aug 19, 2026
@lmolkova
lmolkova added this pull request to the merge queue Aug 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Aug 19, 2026
@lmolkova
lmolkova added this pull request to the merge queue Aug 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Aug 19, 2026
@lmolkova
lmolkova added this pull request to the merge queue Aug 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Aug 19, 2026
@lmolkova
lmolkova added this pull request to the merge queue Aug 19, 2026
Merged via the queue into main with commit 06009cb Aug 19, 2026
111 checks passed
@lmolkova
lmolkova deleted the copilot/support-openai-v3 branch August 19, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support openai v3

5 participants