Skip to content

fix(otel): make lite-bootstrap[fastmcp] importable (api/sdk split)#154

Merged
lesnik512 merged 1 commit into
mainfrom
fix-otel-api-sdk-conflation
Jul 19, 2026
Merged

fix(otel): make lite-bootstrap[fastmcp] importable (api/sdk split)#154
lesnik512 merged 1 commit into
mainfrom
fix-otel-api-sdk-conflation

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

lite-bootstrap[fastmcp] (and any environment with opentelemetry-api but not opentelemetry-sdk) crashed on import lite_bootstrap. Full rationale: planning/changes/2026-07-19.01-fix-otel-api-sdk-conflation.md.

Reproduced on regular (GIL) CPython 3.12:

$ uv pip install "lite-bootstrap[fastmcp]"; python -c "import lite_bootstrap"
  File ".../instruments/opentelemetry_instrument.py", line 18, in <module>
    from opentelemetry.sdk import resources
ModuleNotFoundError: No module named 'opentelemetry.sdk'

Root cause: is_opentelemetry_installed = find_spec("opentelemetry") is True with only opentelemetry-api, but the OTel instrument imports opentelemetry.sdk.*. fastmcp pulls bare opentelemetry-api transitively. (This is the third of three incomplete-opentelemetry-stack bugs; the other two shipped in #153.)

What changed

  • Add import_checker.is_opentelemetry_sdk_installed = _safe_find_spec("opentelemetry.sdk").
  • Gate the instrument's sdk-import block and the pyroscope-processor block on the new flag; check_dependencies() requires both api and sdk. The six api-only consumers (logging trace-injection, framework get_tracer_provider, faststream health-check spans) stay on the api flag.
  • bootstrap() now warns (InstrumentDependencyMissingWarning) instead of silently skipping when opentelemetry_endpoint is set but the gRPC OTLP exporter package is absent.
  • Promotes architecture/instruments.md (three-way api/sdk/exporter guard) and clears the OTel-stack dependency-model deferral. deferred.md fastmcp entry updated — now imports on 3.14t (cffi still blocks 3.13t).

Testing

  • TDD: two regression tests (sdk-absent module reimports cleanly + check_dependencies False; endpoint-without-exporter warns). Both provably fail on pre-fix code.
  • just test: 211 passed, 100% coverage. just lint-ci clean (ty local + latest).
  • Verified uv pip install ".[fastmcp]" + import lite_bootstrap succeeds on regular 3.12.
  • Independent review (reproduced both crashes via worktree revert): ready to merge.

🤖 Generated with Claude Code

is_opentelemetry_installed (find_spec("opentelemetry")) is True with only
opentelemetry-api, but the OTel instrument imports opentelemetry.sdk.* — so
any api-only environment (e.g. lite-bootstrap[fastmcp], which pulls bare
opentelemetry-api transitively) crashed `import lite_bootstrap`. Add
is_opentelemetry_sdk_installed, gate the instrument's sdk imports on it, and
require api+sdk in check_dependencies. Also warn (instead of silently skipping)
when opentelemetry_endpoint is set but the gRPC OTLP exporter is absent.

Promotes architecture/instruments.md (three-way api/sdk/exporter guard) and
clears the OTel-stack dependency-model deferral. Reproduced the crash on a
regular 3.12 interpreter; fixed and verified `[fastmcp]` now imports.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lesnik512
lesnik512 merged commit 763008e into main Jul 19, 2026
10 checks passed
@lesnik512
lesnik512 deleted the fix-otel-api-sdk-conflation branch July 19, 2026 06:52
lesnik512 added a commit that referenced this pull request Jul 19, 2026
Now that the opentelemetry api/sdk split (#154) lets lite-bootstrap[fastmcp]
import in an api-only environment, fastmcp/fastmcp-metrics install and smoke-pass
on 3.14t. Add them to the 3.14t leg's extras; 3.13t stays excluded (cffi gates
free-threading to 3.14+). Verified locally on a real 3.14t interpreter.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant