Skip to content
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

Add support for db cursors and connections in context managers #821

Conversation

carlbordum
Copy link
Contributor

Here is an example snippet that will not report tracing without this patch:

with psycopg2.connect(...) as conn, conn.cursor() as cursor:
    cursor.execute("select 1;")

Here is an example snippet that will not report tracing without this patch:

with psycopg2.connect(...) as conn, conn.cursor() as cursor:
    cursor.execute("select 1;")
@carlbordum carlbordum requested a review from a team as a code owner June 12, 2020 08:14
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 12, 2020

CLA Check
The committers are authorized under a signed CLA.

@carlbordum
Copy link
Contributor Author

I signed it

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @carlbordum. If you could add a unit test for this change and update the changelog, i'd be happy to review and approve.

@carlbordum
Copy link
Contributor Author

@codeboten I want to write the test, but I can't quite figure out how to do it without mocking the entire functionality, which would make the tests pointless. Can you offer any guidance?

@lzchen
Copy link
Contributor

lzchen commented Jul 10, 2020

@carlbordum
Maybe you can write docker tests with real objects to test this? https://github.com/open-telemetry/opentelemetry-python/tree/master/ext/opentelemetry-ext-docker-tests/tests

@codeboten
Copy link
Contributor

@carlbordum I think @lzchen is right, the integration tests are probably the easiest place to test this, there's already some postgres tests you could take a look at

self._cursor.execute("CREATE TABLE IF NOT EXISTS test (id INT)")

@codeboten
Copy link
Contributor

@carlbordum any chance you'll find time to add the integration test?

@ffe4
Copy link
Contributor

ffe4 commented Aug 20, 2020

@codeboten should I write a test and open an alternative PR? The 2020-08-06 SIG notes mention this PR, but I don't know whether you have discussed anything afterwards.

@lzchen
Copy link
Contributor

lzchen commented Aug 20, 2020

@ffe4

Hey thanks for showing interest in this. Yeah due to the lack of activity from the original owner, I think it would be great if you could take the changes and add a test for it. Once you put up a new PR, just tag this one and I will close this.

ffe4 added a commit to ffe4/opentelemetry-python that referenced this pull request Aug 20, 2020
ffe4 added a commit to ffe4/opentelemetry-python that referenced this pull request Aug 21, 2020
@codeboten
Copy link
Contributor

closed by #1028

@codeboten codeboten closed this Sep 2, 2020
srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 2020
Co-authored-by: Olivier Albertini <olivier.albertini@montreal.ca>
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.

None yet

4 participants