Skip to content

fix(milvus): capture span attributes for positionally-passed arguments - #4707

Open
gauravkr2209 wants to merge 3 commits into
traceloop:mainfrom
gauravkr2209:fix/milvus-positional-args
Open

gauravkr2209 wants to merge 3 commits into
traceloop:mainfrom
gauravkr2209:fix/milvus-positional-args

Conversation

@gauravkr2209

@gauravkr2209 gauravkr2209 commented Nov 13, 2026 •

Copy link
Copy Markdown

Problem
The Milvus instrumentation reads request data only from kwargs. MilvusClient.insert(collection_name, data), search(collection_name, data) and delete(collection_name, ids) are valid positional calls. With positional arguments the span loses its data attributes (e.g. client.insert(COLLECTION, ROWS) produced a span missing the collection name and data count).

Fix
Bind the call's args and kwargs to the wrapped method's signature (inspect.signature(...).bind_partial), flatten any **kwargs, skip *args, and fall back to kwargs if binding fails, so behaviour never gets worse. Only the attribute-reading path changes; the wrapped call itself is untouched.

Tests
Added tests/test_positional_args.py (3 tests, real local Milvus Lite in a tmp dir, no network). They fail on main and pass with this change. Full Milvus suite with the fix: 15 passed. ruff check passes on all three files.

Before / after
Before: client.insert(COLLECTION, ROWS) positionally produced a span without the collection name and data count. After: the span carries the collection name and data count (MILVUS_INSERT_DATA_COUNT 2 for 2 rows), identical to the keyword call.

Summary by CodeRabbit

  • Bug Fixes
    • Milvus spans now capture operation attributes when arguments are passed positionally as well as by keyword.
  • Tests
    • Added coverage for positional arguments in insert, search, and delete operations.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Milvus instrumentation now resolves positional and keyword call arguments before setting operation-specific span attributes. Regression tests check span attributes for positional insert, search, and delete calls.

Changes: Milvus Argument Attribute Collection

Layer / File(s) Summary
Resolve wrapped call arguments
packages/opentelemetry-instrumentation-milvus/opentelemetry/instrumentation/milvus/utils.py
get_call_arguments binds inputs to the wrapped function signature, flattens **kwargs, omits *args, and returns keyword arguments if inspection or binding fails.
Use resolved arguments in span attributes
packages/opentelemetry-instrumentation-milvus/opentelemetry/instrumentation/milvus/wrapper.py, packages/opentelemetry-instrumentation-milvus/tests/test_positional_args.py
_wrap passes resolved arguments to operation-specific attribute setters. Tests check collection name and operation-specific count attributes for positional insert, search, and delete calls.

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

Change: Bug fix

Suggested reviewers: josecespedesant

Merge Risk: Minimal · up to e984b

This fixes missing span attributes for positionally passed Milvus arguments. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change: span attributes for Milvus calls that pass arguments positionally. The raw summary and objectives confirm this is the main change. The fix adds get_call_arguments in utils.…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: span attributes for Milvus calls that pass arguments positionally. The raw summary and objectives confirm this is the main change. The fix adds get_call_arguments in utils.py, wires it into wrapper.py, and adds positional-argument tests for insert, search, and delete. The title uses a conventional 'fix(milvus):' scope and a specific subject, and it is 70 characters long.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: be0c211f-7a27-4b75-b146-4930351f3dc8
Commits

Reviewing files that changed from the base of the PR and between e3d651a and e984bef.

Files selected for processing: 3

  • packages/opentelemetry-instrumentation-milvus/opentelemetry/instrumentation/milvus/utils.py
  • packages/opentelemetry-instrumentation-milvus/opentelemetry/instrumentation/milvus/wrapper.py
  • packages/opentelemetry-instrumentation-milvus/tests/test_positional_args.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

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