Skip to content

Conversation

@elinacse
Copy link
Contributor

@elinacse elinacse commented Dec 6, 2025

  • I have added tests that cover my changes.
  • If adding a new instrumentation or changing an existing one, I've added screenshots from some observability platform showing the change.
  • PR name follows conventional commits format: feat(instrumentation): ... or fix(instrumentation): ....
  • (If applicable) I have updated the documentation accordingly.

Important

Enhance Qdrant instrumentation by adding query_points and query_batch_points methods, updating tests, and adding a sample app.

  • Instrumentation Enhancements:
    • Add query_points and query_batch_points methods to qdrant_client_methods.json.
    • Update _instrument() in __init__.py to handle new methods and log errors if instrumentation fails.
    • Modify _wrap() in wrapper.py to support new methods and map them for backward compatibility.
  • Testing:
    • Update test_qdrant_instrumentation.py to test query_points and query_batch_points methods.
  • Sample App:
    • Add qdrant_app.py to demonstrate usage of query_points with a sample dataset.

This description was created by Ellipsis for d096021. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features

    • OpenTelemetry instrumentation added for Qdrant query_points and query_batch_points methods
    • New sample app demonstrating Qdrant integration with embeddings
  • Bug Fixes

    • Improved instrumentation reliability with additional validation and guarded error handling
  • Breaking Changes

    • Public API: search/search_batch and related request fields renamed to query_points/query_batch_points and QueryRequest/query respectively; update integrations accordingly

✏️ Tip: You can customize this high-level summary in your review settings.

@elinacse
Copy link
Contributor Author

elinacse commented Dec 6, 2025

#3492

@coderabbitai
Copy link

coderabbitai bot commented Dec 6, 2025

Walkthrough

Updates add support for QdrantClient.query_points and query_batch_points, extend wrapper attribute handling with backward-compatible naming, add safer instrumentation initialization with exception handling, update tests to new APIs, and add a sample app demonstrating query_points usage.

Changes

Cohort / File(s) Summary
Instrumentation initialization
packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/__init__.py
Tightened target-class and method existence checks and wrapped wrap_function_wrapper calls in try/except to log warnings and avoid crashes on instrumentation failures.
Method mappings
packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/qdrant_client_methods.json
Added mappings for QdrantClient.query_points (span qdrant.query_points) and QdrantClient.query_batch_points (span qdrant.query_batch_points).
Wrapper logic
packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/wrapper.py
Included query_points and query_batch_points in attribute collection paths; added backward-compatibility name mapping so attributes for these methods report under existing search/search_batch attribute keys.
Tests
packages/opentelemetry-instrumentation-qdrant/tests/test_qdrant_instrumentation.py
Updated tests to call query_points/query_batch_points, switched model usages from SearchRequestQueryRequest and vectorquery, and adjusted span name and attribute assertions.
Sample application
packages/sample-app/sample_app/qdrant_app.py
New example script demonstrating embeddings, collection creation/upsert, and a query_points call with Traceloop instrumentation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to backward-compatibility mapping in wrapper.py for single and batch flows.
  • Verify exception handling and logging in __init__.py doesn't obscure real errors.
  • Ensure tests reflect the new request model fields and span names correctly.

Possibly related issues

Suggested reviewers

  • nirga

Poem

🐰 I hopped through code with nimble feet,
New queries now make tracing neat.
Mapped old names so none would stray,
Wrapped with care to save the day.
🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title is partially related to the changeset. It mentions supporting 'all versions of qdrant package' but the actual changes focus specifically on adding instrumentation for two new query methods (query_points and query_batch_points) with backward-compatibility mappings, not supporting multiple versions. Clarify the title to reflect the main change: either specify that it adds instrumentation for the new query methods, or if version support is the focus, explain how the changes support multiple versions.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to d096021 in 1 minute and 25 seconds. Click for details.
  • Reviewed 212 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/__init__.py:54
  • Draft comment:
    Good defensive wrapping with try/except; consider using logger.exception (or including the traceback) to help with debugging instrumentation failures.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
2. packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/qdrant_client_methods.json:47
  • Draft comment:
    New methods 'query_points' and 'query_batch_points' have been added. Ensure these names match the actual Qdrant client API and that any breaking changes are documented.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
3. packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/wrapper.py:64
  • Draft comment:
    The wrapper now includes 'query_points' and 'query_batch_points' (with backward-compatible mapping to 'search' and 'search_batch'). Consider updating docstrings or external docs to reflect this behavior.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
4. packages/opentelemetry-instrumentation-qdrant/tests/test_qdrant_instrumentation.py:80
  • Draft comment:
    Test updates now invoke 'query_points' and 'query_batch_points'. Verify if legacy search methods should also retain tests for backward compatibility.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
5. packages/sample-app/sample_app/qdrant_app.py:47
  • Draft comment:
    Sample app correctly uses the new 'query_points' method. For style consistency, please ensure the file ends with a newline.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
6. packages/opentelemetry-instrumentation-qdrant/tests/test_qdrant_instrumentation.py:87
  • Draft comment:
    Typo noticed: The function name 'test_qdrant_searchs' may be incorrect (possibly intended to be 'test_qdrant_search' or 'test_qdrant_searches'). Please confirm the intended naming.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_gaDPKGYPVWlPX25K

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@elinacse elinacse changed the title qdrantPackageFix fix(qdrant):changes to support all versions of qdrant package Dec 6, 2025
@elinacse
Copy link
Contributor Author

elinacse commented Dec 6, 2025

@nirga @gyliu513 I have submitted this PR for the issue FIx #3492
Added the sample which I have tested with qdrant latest version 1.16.1, some methods are deprecated in latest version of qdrant and 2 users have reported in the issue . Hence I have replaced with the appropriate methods. Please review the PR . Thanks !

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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

54-68: Narrow the exception handling to specific exception types.

Catching broad Exception can mask unexpected errors. Consider catching specific exceptions that wrap_function_wrapper might raise, such as AttributeError, ImportError, or ValueError.

Apply this diff:

             target_class = getattr(qdrant_client, wrap_object, None)
             if target_class and hasattr(target_class, wrap_method):
                 try:
                     wrap_function_wrapper(
                         MODULE,
                         f"{wrap_object}.{wrap_method}",
                         _wrap(tracer, wrapped_method),
                     )
-                except Exception as e:
+                except (AttributeError, ImportError, ValueError) as e:
                     logger.warning(
                         "Failed to instrument %s.%s: %s",
                         wrap_object,
                         wrap_method,
                         str(e),
                     )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f782741 and d3031b2.

📒 Files selected for processing (5)
  • packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/__init__.py (1 hunks)
  • packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/qdrant_client_methods.json (1 hunks)
  • packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/wrapper.py (3 hunks)
  • packages/opentelemetry-instrumentation-qdrant/tests/test_qdrant_instrumentation.py (3 hunks)
  • packages/sample-app/sample_app/qdrant_app.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.py: Store API keys only in environment variables/secure vaults; never hardcode secrets in code
Use Flake8 for code linting and adhere to its rules

Files:

  • packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/__init__.py
  • packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/wrapper.py
  • packages/sample-app/sample_app/qdrant_app.py
  • packages/opentelemetry-instrumentation-qdrant/tests/test_qdrant_instrumentation.py
🧬 Code graph analysis (3)
packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/__init__.py (2)
packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/wrapper.py (1)
  • _wrap (31-76)
packages/opentelemetry-instrumentation-weaviate/opentelemetry/instrumentation/weaviate/wrapper.py (1)
  • _wrap (34-51)
packages/sample-app/sample_app/qdrant_app.py (1)
packages/traceloop-sdk/traceloop/sdk/__init__.py (2)
  • Traceloop (36-267)
  • init (48-198)
packages/opentelemetry-instrumentation-qdrant/tests/test_qdrant_instrumentation.py (2)
packages/opentelemetry-instrumentation-qdrant/tests/conftest.py (1)
  • exporter (12-22)
packages/traceloop-sdk/traceloop/sdk/utils/in_memory_span_exporter.py (1)
  • get_finished_spans (40-43)
🪛 Flake8 (7.3.0)
packages/sample-app/sample_app/qdrant_app.py

[error] 4-4: 'numpy as np' imported but unused

(F401)

🪛 Ruff (0.14.7)
packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/__init__.py

62-62: Do not catch blind exception: Exception

(BLE001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Test Packages (3.12)
  • GitHub Check: Test Packages (3.11)
  • GitHub Check: Test Packages (3.10)
  • GitHub Check: Build Packages (3.11)
  • GitHub Check: Lint
🔇 Additional comments (3)
packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/qdrant_client_methods.json (1)

47-51: LGTM!

The new method mappings for query_points and query_batch_points are properly structured and consistent with the existing entries.

Also applies to: 57-61

packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/wrapper.py (1)

64-64: LGTM! Excellent backward compatibility approach.

The additions of query_points and query_batch_points are well-implemented with backward-compatible attribute naming. This ensures existing monitoring and alerting systems continue to work while the span names reflect the new API methods.

Also applies to: 70-70, 81-92, 122-124

packages/opentelemetry-instrumentation-qdrant/tests/test_qdrant_instrumentation.py (1)

80-98: LGTM! Tests properly validate new APIs and backward compatibility.

The test updates correctly exercise the new query_points and query_batch_points methods with updated models (QueryRequest), while importantly verifying that the backward-compatible attribute names (e.g., QDRANT_SEARCH_COLLECTION_NAME) are still populated correctly.

Also applies to: 102-124

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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

60-71: Wiring query_points / query_batch_points into existing search paths looks correct

Including query_points in the search-like branch and query_batch_points in the batch-search branch cleanly reuses the existing attribute logic without changing behavior for older methods. This is a straightforward, compatible extension.

If you want to keep style consistent with the multi-line list above, you could also break the line at Line 70 into a multi-line list, but that’s purely optional.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d3031b2 and 1c5f47f.

📒 Files selected for processing (2)
  • packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/wrapper.py (3 hunks)
  • packages/sample-app/sample_app/qdrant_app.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/sample-app/sample_app/qdrant_app.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.py: Store API keys only in environment variables/secure vaults; never hardcode secrets in code
Use Flake8 for code linting and adhere to its rules

Files:

  • packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/wrapper.py
🧬 Code graph analysis (1)
packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/wrapper.py (6)
packages/opentelemetry-instrumentation-milvus/opentelemetry/instrumentation/milvus/wrapper.py (2)
  • _set_search_attributes (280-328)
  • _set_span_attribute (53-57)
packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/__init__.py (1)
  • _set_span_attribute (31-38)
packages/opentelemetry-instrumentation-watsonx/opentelemetry/instrumentation/watsonx/__init__.py (1)
  • _set_span_attribute (105-109)
packages/opentelemetry-instrumentation-llamaindex/opentelemetry/instrumentation/llamaindex/custom_llm_instrumentor.py (1)
  • _set_span_attribute (71-75)
packages/opentelemetry-instrumentation-chromadb/opentelemetry/instrumentation/chromadb/wrapper.py (1)
  • _set_span_attribute (26-30)
packages/opentelemetry-instrumentation-weaviate/opentelemetry/instrumentation/weaviate/wrapper.py (1)
  • _set_span_attribute (26-30)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build Packages (3.11)
  • GitHub Check: Test Packages (3.12)
  • GitHub Check: Test Packages (3.10)
  • GitHub Check: Test Packages (3.11)
  • GitHub Check: Lint
🔇 Additional comments (2)
packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/wrapper.py (2)

79-91: Backward-compatible attribute_method mapping is consistent and avoids new attribute keys

Using attribute_method to map:

  • query_pointssearch
  • query_batch_pointssearch_batch

before constructing qdrant.{attribute_method}.collection_name keeps all collection-name attributes under the existing qdrant.search.* / qdrant.search_batch.* namespaces, which helps avoid fragmenting metrics across old and new method names.

This looks correct and consistent with the intent of supporting newer client APIs without breaking existing dashboards.


119-123: Batch search attribute mapping for query_batch_points matches collection-name behavior

Defaulting requests to an empty list and then mapping:

  • attribute_method = "search_batch" when method == "query_batch_points"

so that you emit qdrant.search_batch.requests_count keeps batch request-count metrics aligned with the prior search_batch naming. This mirrors the mapping in _set_collection_name_attribute and maintains backward compatibility without changing behavior for other batch methods.

No issues here.

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