Repository navigation
fix(qdrant): resolve positional args to kwargs in instrumentation wrappers - #1968
todkarsant wants to merge 2 commits into
Conversation
…ppers When Qdrant client methods (upsert, query_points, delete, retrieve, scroll, etc.) are called with positional arguments, the instrumentation wrappers only forwarded kwargs to process_qdrant_response, causing span attributes like collection_name and data counts to be lost. Use inspect.signature to bind positional args to their parameter names before extracting telemetry attributes. Applied to both sync and async wrappers. Closes openlit#1905
Reviewer's GuideImplementationBind positional arguments to parameter names for telemetry extraction in both Qdrant wrappers while preserving the original arguments for the wrapped call.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@AmanAgarwal041 Could you review this? Fixes Qdrant instrumentation dropping span attributes when methods are called with positional arguments. Thanks! |
PR Summary by QodoFix positional-argument telemetry in Qdrant wrappers
AI Description
Merge Risk
|
Code Review by Qodo
1.
|
Linked issuesChecked at commit f7b37c2 #1905 Bug: Qdrant instrumentation drops span attributes for positionally-passed arguments · 1 of 1 met
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="sdk/python/src/openlit/instrumentation/qdrant/qdrant.py" line_range="47-49" />
<code_context>
+ # how the caller invoked the method.
+ try:
+ sig = inspect.signature(wrapped)
+ bound = sig.bind(*args, **kwargs)
+ bound.apply_defaults()
+ kwargs = bound.arguments
+ except (TypeError, ValueError):
+ pass
</code_context>
<issue_to_address>
**Positional Qdrant calls fail**
When a sync or async wrapped Qdrant method receives positional arguments, `kwargs = bound.arguments` puts those arguments in `kwargs` while leaving them in `args`, so `wrapped(*args, **kwargs)` passes them twice and raises `TypeError` before the Qdrant operation runs; callers see the operation fail.
Keep the original `args` and `kwargs` for invoking `wrapped`, and use the bound arguments separately for telemetry in both wrappers.
Also at `sdk/python/src/openlit/instrumentation/qdrant/async_qdrant.py:47-49`.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: sdk/python/src/openlit/instrumentation/qdrant/qdrant.py:49
bound.arguments was assigned back to kwargs, but the original args were still passed to wrapped(*args, **kwargs), causing TypeError from duplicate arguments. Now bound.arguments is stored in telemetry_kwargs used only for span attributes, while original args/kwargs go to wrapped().
|
Addressed the Sourcery finding in f7b37c2: The previous code assigned Fixed by storing bound arguments in a separate |
Fixes #1905
When Qdrant client methods (upsert, query_points, delete, retrieve, scroll, etc.) are called with positional arguments, span attributes like
collection_nameand data counts are lost because the wrappers only forwardedkwargstoprocess_qdrant_response.Changes
inspect.signature+bind()to resolve positional args into named kwargs before extracting telemetry attributesqdrant.py) and async (async_qdrant.py) wrappersBefore
client.upsert("demo", POINTS)-> spanUPSERT unknown,db.vector.count=0After
client.upsert("demo", POINTS)-> spanUPSERT demo,db.vector.count=NSummary by Sourcery
Bug Fixes: