-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support cursor based queries #2501
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR but you need to add tests
What do you have in mind? The existing code is also just testing if the function gets wrapped. Do the same for the Cursor class? |
Given the code you have added would be nice to assert that a Span gets created with the attributes you set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you are at it please add a test asserting that the span gets created. You are adding 40 lines that are not tested
Do you have examples on how to do this? The current code does not have any of this at the moment. This also means I will need a postgres database to actually connect to. |
This is redis instrumentation mocking the wrapped function: Can something like this work? |
It would test if we can instrument a mock and that it generates spans. Not sure what the value is of that? |
The value is to check that |
This project also seems to use pytest however it is not clear to me how it can execute async test cases. Do you have pointer on this? |
I would take a look at the instrumentation current tests in |
I looked at them. The problem is that there is something different there that makes pytest execute those tests correct and not the ones that I added. Both when invoking pytest directly and using the predefined tox environments.
It does not detect them as async. I will push my change, maybe you can spot the issue. This test should fail but it doesn't because it never gets awaited. |
instrumentation/opentelemetry-instrumentation-asyncpg/tests/test_asyncpg_wrapper.py
Outdated
Show resolved
Hide resolved
instrumentation/opentelemetry-instrumentation-asyncpg/tests/test_asyncpg_wrapper.py
Outdated
Show resolved
Hide resolved
@bartv next time please configure pre-commit as documented in CONTRIBUTING |
ok. done. Do you squash merge or do I need to squash the commit history myself? |
How do I handle this error?
anext only exists in python3.10 and later. I switched to calling |
Does something like this work? Otherwise just silence the warning with a pylint comment and open an issue with the exact line to fix properly
|
…n-contrib into cursor-queries
@xrmx What do I need to do to get this merged? |
I'll merge this PR ✌️ |
Description
This PR add support for tracing on queries using a cursor instead of directly on the connection.
Type of change
New feature (non-breaking change which adds functionality)
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.