Skip to content

Pin OTel FastAPI/httpx instrumentation to >=0.64b0 - #19

Merged
anth-volk merged 2 commits into
mainfrom
fix/pin-otel-instrumentation-fastapi
Jul 2, 2026
Merged

Pin OTel FastAPI/httpx instrumentation to >=0.64b0#19
anth-volk merged 2 commits into
mainfrom
fix/pin-otel-instrumentation-fastapi

Conversation

@anth-volk

Copy link
Copy Markdown
Contributor

Fixes #18

Problem

opentelemetry-instrumentation-fastapi and -httpx were declared in core dependencies with no version floor. FastAPI 0.137.0 changed include_router to append a lazily-matching _IncludedRouter (no .path); opentelemetry-instrumentation-fastapi < 0.64b0 reads route.path on the matched route and raises AttributeError: '_IncludedRouter' object has no attribute 'path' on CORS preflight OPTIONS requests → unhandled 500.

This took down a downstream consumer (policyengine-uk-chat) in production — every browser preflight 500'd. It affects any consumer that enables instrument_fastapi on FastAPI ≥ 0.137.

Upstream: open-telemetry/opentelemetry-python-contrib#4699, fixed in opentelemetry-instrumentation-fastapi 0.64b0 (2026-06-24).

Change

  • Pin opentelemetry-instrumentation-fastapi>=0.64b0 and opentelemetry-instrumentation-httpx>=0.64b0 (same coordinated OTel release train — kept aligned).
  • Refresh uv.lock: the OTel train moves 0.63b1 → 0.64b0 (SDK 1.42.1 → 1.43.0).
  • Towncrier fragment under changelog.d/.

Verification

  • uv lock resolves cleanly to opentelemetry-instrumentation-fastapi==0.64b0 / -httpx==0.64b0.
  • ruff format --check . and ruff check .: clean.
  • coverage run -m pytest: 123 passed against OTel 0.64b0; coverage report meets the 90% gate.

Follow-up (not in this PR)

Per this repo's fail-open guidance, the FastAPI adapter should degrade rather than propagate a per-request instrumentor error. The crash is inside OpenTelemetry's own ASGI middleware, so that needs an adapter-level guard rather than the setup-time try/except around instrument_app() we have today. Worth a separate hardening issue so a future instrumentor incompatibility can't 500 live requests.

opentelemetry-instrumentation-fastapi < 0.64b0 raises AttributeError on
FastAPI >= 0.137 include_router routing (`_IncludedRouter` has no `.path`),
500-ing every CORS preflight for consumers that enable FastAPI
instrumentation (took down policyengine-uk-chat in production). The upstream
fix shipped in 0.64b0; pin both instrumentation packages to that floor and
refresh the lock.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@anth-volk

Copy link
Copy Markdown
Contributor Author

The fail-open hardening follow-up noted above is now tracked in #20.

Extend the forward pins to opentelemetry-api/-sdk and both OTLP exporters
(>=1.43.0) alongside the instrumentation floor (>=0.64b0), so consumers get a
self-consistent OTel stack at the coordinated known-good release rather than a
patched instrumentor over a drifting core.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@anth-volk
anth-volk marked this pull request as ready for review July 2, 2026 19:31
@anth-volk
anth-volk merged commit ac9a365 into main Jul 2, 2026
3 checks passed
@anth-volk
anth-volk deleted the fix/pin-otel-instrumentation-fastapi branch July 2, 2026 19:31
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.

Pin opentelemetry-instrumentation-fastapi and -httpx to >=0.64b0 (FastAPI >=0.137 _IncludedRouter crash)

1 participant