Skip to content

fix(qdrant): skip missing client methods#4349

Open
1cbyc wants to merge 2 commits into
traceloop:mainfrom
1cbyc:fix/issue-3492
Open

fix(qdrant): skip missing client methods#4349
1cbyc wants to merge 2 commits into
traceloop:mainfrom
1cbyc:fix/issue-3492

Conversation

@1cbyc

@1cbyc 1cbyc commented Jul 4, 2026

Copy link
Copy Markdown

What Problem This Solves

versions that no longer expose were still being instrumented, which can raise an during .

Why This Change Was Made

The instrumentor now uses a static attribute lookup before wrapping methods, so dynamic class lookup cannot falsely report removed methods as present. I also added a regression test with a fake Qdrant client that only exposes through metaclass lookup.

User Impact

Users on newer releases can instrument Qdrant without the startup crash. Existing spans for supported methods still work.

Evidence

  • ============================= test session starts ==============================
    platform linux -- Python 3.10.19, pytest-8.4.2, pluggy-1.6.0
    rootdir: /tmp/openllmetry-3492/packages/opentelemetry-instrumentation-qdrant
    configfile: pyproject.toml
    plugins: anyio-4.12.1, sugar-1.0.0
    collected 6 items

tests/test_missing_methods.py .. [ 33%]
tests/test_qdrant_instrumentation.py .... [100%]

============================== 6 passed in 0.05s ===============================\n-
All checks passed!\n\nFixes #3492

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes
    • Improved Qdrant instrumentation to only wrap/unwrap methods that are statically present on the client.
    • Avoided potential issues caused by dynamically resolved attributes during instrumentation and cleanup.
    • Increased reliability for both sync and async Qdrant client integrations.
  • Tests
    • Added coverage to verify methods that are dynamically provided are skipped for both instrumenting and uninstrumenting.

@CLAassistant

CLAassistant commented Jul 4, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3094baf6-0d04-4e2b-aa42-2531a52f7228

📥 Commits

Reviewing files that changed from the base of the PR and between 8ad8c28 and 823044e.

📒 Files selected for processing (1)
  • packages/opentelemetry-instrumentation-qdrant/tests/test_missing_methods.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/opentelemetry-instrumentation-qdrant/tests/test_missing_methods.py

📝 Walkthrough

Walkthrough

The Qdrant instrumentor now uses inspect.getattr_static through a new helper to detect client methods without triggering dynamic attribute resolution. Tests cover dynamically provided methods and confirm instrumenting and uninstrumenting skip them.

Changes

Static Attribute Detection Fix

Layer / File(s) Summary
Static attribute helper and instrument/uninstrument checks
packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/__init__.py
Adds getattr_static import, a _MISSING sentinel, and _has_static_attribute; replaces hasattr checks with this helper in both _instrument and _uninstrument.
Tests for static attribute detection
packages/opentelemetry-instrumentation-qdrant/tests/test_missing_methods.py
Adds fake sync/async client classes with a dynamic-attribute metaclass and tests that _has_static_attribute, _instrument(), and _uninstrument() ignore dynamically resolved upload_records while handling statically declared methods.

Estimated code review effort: 2 (Simple) | ~10 minutes

Related issues: #3492

Suggested labels: bug, qdrant, instrumentation

Suggested reviewers: nirga, galkleinman

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: skipping missing Qdrant client methods.
Linked Issues check ✅ Passed The fix matches the linked bug by avoiding wrapping removed Qdrant methods while preserving instrumentation for available ones.
Out of Scope Changes check ✅ Passed The changes stay focused on the Qdrant instrumentation fix and its regression tests with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/opentelemetry-instrumentation-qdrant/tests/test_missing_methods.py (1)

1-53: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Solid regression coverage for the metaclass edge case.

The metaclass __getattr__ trick correctly reproduces the scenario where hasattr would return True for a removed method while getattr_static correctly reports it absent, and the instrumentor test verifies wrapping is skipped accordingly. Consider adding a mirrored assertion (or a small follow-up test) for _uninstrument to cover the symmetric code path, though it shares the same helper already validated here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/opentelemetry-instrumentation-qdrant/tests/test_missing_methods.py`
around lines 1 - 53, The new regression test covers _instrument on the metaclass
edge case, but the symmetric _uninstrument path is still unverified. Add a small
companion test near test_instrumentor_skips_methods_missing_from_client_class
that uses the same _FakeQdrantClient, _FakeAsyncQdrantClient, and monkeypatch
setup to assert QdrantInstrumentor()._uninstrument also skips upload_records
while handling upload_points correctly, so both instrument and uninstrument use
the same static-attribute check behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/opentelemetry-instrumentation-qdrant/tests/test_missing_methods.py`:
- Around line 1-53: The new regression test covers _instrument on the metaclass
edge case, but the symmetric _uninstrument path is still unverified. Add a small
companion test near test_instrumentor_skips_methods_missing_from_client_class
that uses the same _FakeQdrantClient, _FakeAsyncQdrantClient, and monkeypatch
setup to assert QdrantInstrumentor()._uninstrument also skips upload_records
while handling upload_points correctly, so both instrument and uninstrument use
the same static-attribute check behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ed67e460-f22c-4e8f-ae89-b64a1f87c4c0

📥 Commits

Reviewing files that changed from the base of the PR and between 93429cf and 8ad8c28.

📒 Files selected for processing (2)
  • packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/__init__.py
  • packages/opentelemetry-instrumentation-qdrant/tests/test_missing_methods.py

@1cbyc

1cbyc commented Jul 7, 2026

Copy link
Copy Markdown
Author

Added companion coverage for the static-attribute check in the _uninstrument path.

Verification run locally from packages/opentelemetry-instrumentation-qdrant:

  • uv run --group test pytest tests/test_missing_methods.py -> 3 passed
  • uv run ruff check tests/test_missing_methods.py -> passed

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.

2 participants