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 asyncpg instrumentation in Elastic APM #889

Merged
merged 32 commits into from
Aug 27, 2020
Merged

Add asyncpg instrumentation in Elastic APM #889

merged 32 commits into from
Aug 27, 2020

Conversation

odimko
Copy link
Contributor

@odimko odimko commented Jul 17, 2020

What does this pull request do?

Adds support for the asyncpg database interface library for Python and PostgreSQL by implementing corresponding instrumentation in the APM agent.

Related issues

#755

Closes issues

#755

@cla-checker-service
Copy link

cla-checker-service bot commented Jul 17, 2020

💚 CLA has been signed

@apmmachine
Copy link
Contributor

apmmachine commented Jul 17, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Started by user Benjamin Wohlwend, Replayed #38]

  • Start Time: 2020-08-27T12:29:11.542+0000

  • Duration: 29 min 1 sec

Test stats 🧪

Test Results
Failed 0
Passed 10927
Skipped 8506
Total 19433

Steps errors

Expand to view the steps failures

  • Name: Shell Script
    • Description: ./tests/scripts/docker/run_tests.sh pypy-3 django-2.0

    • Duration: 3 min 56 sec

    • Start Time: 2020-08-27T12:36:06.636+0000

    • log

@odimko odimko changed the title Add a new file Add asyncpg instrumentation in Elastic APM Jul 17, 2020
@basepi
Copy link
Contributor

basepi commented Jul 17, 2020

Heya @odimko! Thanks for this!

Please sign the CLA when you get a chance. Do you think you'll be able to add some tests here as well?

@odimko
Copy link
Contributor Author

odimko commented Jul 21, 2020

hey there @basepi! Thanks for checking out my PR. it's not ready yet, so more commits will come (I need to update the tests).

@odimko odimko marked this pull request as ready for review July 21, 2020 14:15
@basepi
Copy link
Contributor

basepi commented Jul 21, 2020

Nope, shows signed. Sometimes it just lags a bit. Thanks, this looks awesome!

@odimko
Copy link
Contributor Author

odimko commented Jul 23, 2020

hey @basepi! Could you let me know how I can run CI tests as I am currently getting this error:
githubPrCheckApproved: The PR is not allowed to run in the CI yet. (Only users with write permissions can do so.), thus, I can't check my tests.

@odimko
Copy link
Contributor Author

odimko commented Jul 30, 2020

hi @basepi :) I was wondering if you have had some time to have a look at my comment above :)

@sethmlarson
Copy link
Contributor

sethmlarson commented Jul 30, 2020

@odimko FYI @basepi has been on vacation for the past week and will review when he returns 🛬

@odimko
Copy link
Contributor Author

odimko commented Jul 30, 2020

thanks for letting me know @sethmlarson 🥇

Copy link
Contributor

@beniwohli beniwohli left a comment

Choose a reason for hiding this comment

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

@odimko this is great, thanks! And sorry for the long turnaround on the review, both @basepi and me were on PTO

elasticapm/instrumentation/register.py Outdated Show resolved Hide resolved
elasticapm/instrumentation/packages/asyncio/asyncpg.py Outdated Show resolved Hide resolved
.ci/.jenkins_framework.yml Show resolved Hide resolved
@odimko
Copy link
Contributor Author

odimko commented Aug 3, 2020

@odimko this is great, thanks! And sorry for the long turnaround on the review, both @basepi and me were on PTO

hey @beniwohli and @basepi! I have implemented all the requested changes. Please have a look at the PR if it looks good now and let me know if I should improve anything else :)

@beniwohli
Copy link
Contributor

@odimko great work on the updates. The tests currently fails because asyncpg isn't able to parse the DSN. Turns out that for asyncpg, the DSN has a different format than psycopg2, using a URL format:

https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.connection.connect

You should be able to adapt the dsn() function in your asyncpg tests easily.

@odimko
Copy link
Contributor Author

odimko commented Aug 25, 2020

@beniwohli and @basepi, hey there :)
please have a look at the latest changes to the PR, I've switched to use the yield approach as suggested (since we are moving towards Python 3.5 deprecation). Is there anything else left to do?

all tests pass successfully except for linting. any suggestions on how I can run it? otherwise, I would appreciate if someone could run it so that the last flailing check will pass :)

@basepi basepi requested a review from beniwohli August 26, 2020 19:33
Copy link
Contributor

@beniwohli beniwohli left a comment

Choose a reason for hiding this comment

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

This looks great! Thanks a lot for your contribution and sorry about the sometimes slow answer times!

docs/supported-technologies.asciidoc Outdated Show resolved Hide resolved
@beniwohli beniwohli merged commit 4bef64b into elastic:master Aug 27, 2020
@odimko odimko deleted the add_support_asyncpg branch August 27, 2020 21:39
@odimko
Copy link
Contributor Author

odimko commented Aug 27, 2020

This looks great! Thanks a lot for your contribution and sorry about the sometimes slow answer times!

No problem at all! Thanks for supporting with it 🥇

@beniwohli, may I ask you when it will be released?

@basepi
Copy link
Contributor

basepi commented Sep 1, 2020

We don't currently have a release date planned, but I expect it will be Soon (tm) since we have a couple of useful features that are currently unreleased (and since we no longer need to include the removal of py3.5 in the release).

@odimko
Copy link
Contributor Author

odimko commented Sep 1, 2020

We don't currently have a release date planned, but I expect it will be Soon (tm) since we have a couple of useful features that are currently unreleased (and since we no longer need to include the removal of py3.5 in the release).

got it, thanks for explaining!

@odimko
Copy link
Contributor Author

odimko commented Sep 21, 2020

Good morning @basepi and @beniwohli! just checking in to check what is your plan regarding releasing the next version of the APM package. could you please let me know?

@basepi
Copy link
Contributor

basepi commented Sep 22, 2020

Very soon. We'd really like to get #927 in, but it needs some test fixes.

@odimko
Copy link
Contributor Author

odimko commented Sep 22, 2020

perfect, thanks for the update!

@basepi
Copy link
Contributor

basepi commented Sep 23, 2020

It's out! https://github.com/elastic/apm-agent-python/releases/tag/v5.9.0

@odimko
Copy link
Contributor Author

odimko commented Sep 24, 2020

It's out! https://github.com/elastic/apm-agent-python/releases/tag/v5.9.0

awesome! thanks a lot!

stj added a commit to stj/apm-agent-python that referenced this pull request Oct 5, 2020
Issue elastic#889 added instrumentation for asyncpg, though only `execute` and
`executemany` were instrumented. This extends the instrumentation to
include `fetch`, `fetchval` and `fetchrow` methods.
basepi pushed a commit that referenced this pull request Oct 5, 2020
Issue #889 added instrumentation for asyncpg, though only `execute` and
`executemany` were instrumented. This extends the instrumentation to
include `fetch`, `fetchval` and `fetchrow` methods.
romulorosa pushed a commit to romulorosa/apm-agent-python that referenced this pull request Oct 15, 2020
* Add a new file

* Add AsyncPGInstrumentation to register.py

* Fix a typo in register.py

* Use correct function for registering

* Update the docs + add a template for the tests

* Update variable names in the tests

* Add asyncpg.sh for the tests

* Remove unused docstrings

* Improve tests

* Remove callproc test

* PR suggestions

* FIx tests: use URI instead of explicit parameters

* FIx tests: implement further PR suggestions

* FIx tests: implement more PR suggestions

* Use Connection.execute and Connection.executemany instead of Connection._do_execute

* Remove unnecessary requirements

* Fix a type in the tests

* Use yield and proper awaiting in the tests

* Use yield and proper awaiting in the tests + fix a typo

* Fix tests

* Additional fixes to tests

* fix typo

Co-authored-by: Colton Myers <colton.myers@gmail.com>
Co-authored-by: Benjamin Wohlwend <bw@piquadrat.ch>
romulorosa pushed a commit to romulorosa/apm-agent-python that referenced this pull request Oct 15, 2020
Issue elastic#889 added instrumentation for asyncpg, though only `execute` and
`executemany` were instrumented. This extends the instrumentation to
include `fetch`, `fetchval` and `fetchrow` methods.
romulorosa pushed a commit to romulorosa/apm-agent-python that referenced this pull request Oct 15, 2020
* Add a new file

* Add AsyncPGInstrumentation to register.py

* Fix a typo in register.py

* Use correct function for registering

* Update the docs + add a template for the tests

* Update variable names in the tests

* Add asyncpg.sh for the tests

* Remove unused docstrings

* Improve tests

* Remove callproc test

* PR suggestions

* FIx tests: use URI instead of explicit parameters

* FIx tests: implement further PR suggestions

* FIx tests: implement more PR suggestions

* Use Connection.execute and Connection.executemany instead of Connection._do_execute

* Remove unnecessary requirements

* Fix a type in the tests

* Use yield and proper awaiting in the tests

* Use yield and proper awaiting in the tests + fix a typo

* Fix tests

* Additional fixes to tests

* fix typo

Co-authored-by: Colton Myers <colton.myers@gmail.com>
Co-authored-by: Benjamin Wohlwend <bw@piquadrat.ch>
romulorosa pushed a commit to romulorosa/apm-agent-python that referenced this pull request Oct 15, 2020
Issue elastic#889 added instrumentation for asyncpg, though only `execute` and
`executemany` were instrumented. This extends the instrumentation to
include `fetch`, `fetchval` and `fetchrow` methods.
beniwohli added a commit to beniwohli/apm-agent-python that referenced this pull request Sep 14, 2021
* Add a new file

* Add AsyncPGInstrumentation to register.py

* Fix a typo in register.py

* Use correct function for registering

* Update the docs + add a template for the tests

* Update variable names in the tests

* Add asyncpg.sh for the tests

* Remove unused docstrings

* Improve tests

* Remove callproc test

* PR suggestions

* FIx tests: use URI instead of explicit parameters

* FIx tests: implement further PR suggestions

* FIx tests: implement more PR suggestions

* Use Connection.execute and Connection.executemany instead of Connection._do_execute

* Remove unnecessary requirements

* Fix a type in the tests

* Use yield and proper awaiting in the tests

* Use yield and proper awaiting in the tests + fix a typo

* Fix tests

* Additional fixes to tests

* fix typo

Co-authored-by: Colton Myers <colton.myers@gmail.com>
Co-authored-by: Benjamin Wohlwend <bw@piquadrat.ch>
beniwohli pushed a commit to beniwohli/apm-agent-python that referenced this pull request Sep 14, 2021
Issue elastic#889 added instrumentation for asyncpg, though only `execute` and
`executemany` were instrumented. This extends the instrumentation to
include `fetch`, `fetchval` and `fetchrow` methods.
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.

6 participants