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

PyMySQL Integration #504

Merged
merged 17 commits into from
Apr 24, 2020
Merged

PyMySQL Integration #504

merged 17 commits into from
Apr 24, 2020

Conversation

lzchen
Copy link
Contributor

@lzchen lzchen commented Mar 17, 2020

Integration for PyMySQL.
Fixes some documentation as well for other db integrations.
Leverages dbapi.

@lzchen lzchen requested a review from a team March 17, 2020 21:02
@lzchen lzchen added the needs reviewers PRs with this label are ready for review and needs people to review to move forward. label Mar 18, 2020
Copy link
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

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

A few changes requested only 👍

ext/opentelemetry-ext-dbapi/README.rst Outdated Show resolved Hide resolved
Copy link
Member

@hectorhdzg hectorhdzg left a comment

Choose a reason for hiding this comment

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

LGTM, like mentioned in SIG meeting this morning it would be good to have functional tests for this, would be good to create a task for it, thanks for fixing issues in other integrations

@lzchen lzchen requested a review from ocelotl March 20, 2020 19:03
@lzchen
Copy link
Contributor Author

lzchen commented Apr 13, 2020

@hectorhdzg I've added functional tests, they are basically the exact same as Mysql except using the PyMySQL library

@ocelotl I believe I've addressed all your comments

@codeboten codeboten added the instrumentation Related to the instrumentation of third party libraries or frameworks label Apr 17, 2020
Copy link
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

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

I just added a few comments, but the main changes I will request is to integrate this with the current instrumentation API. This is mainly a matter of creating a class that inherits from BaseIinstrumentor. The implementation of its _instrument method should be just what you already have in trace_integration if I am not mistaken.

You'll probably need to pass a tracer argument to _instrument, I am updating the API here to do that. Please reach out if you have any questions.

@@ -146,6 +146,9 @@ def get_connection_attributes(self, connection):
self.name = self.database_component
self.database = self.connection_props.get("database", "")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.database = self.connection_props.get("database", "")
self.database = self.connection_props.get("database", b"")

Comment on lines +150 to +151
if hasattr(self.database, "decode"):
self.database = self.database.decode(errors="ignore")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if hasattr(self.database, "decode"):
self.database = self.database.decode(errors="ignore")
self.database = self.database.decode(errors="ignore")

Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a comment

Choose a reason for hiding this comment

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

Overall speaking the PR looks good.

You can address my comments before merging or we can address then in new PRs.

Comment on lines 1 to 3
.. include:: ../../../ext/opentelemetry-ext-pymysql/README.rst


Choose a reason for hiding this comment

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

Currently we're not including that readme in these files anymore.

ext/opentelemetry-ext-mysql/setup.cfg Outdated Show resolved Hide resolved
ext/opentelemetry-ext-pymysql/setup.cfg Outdated Show resolved Hide resolved
ext/opentelemetry-ext-pymysql/setup.cfg Outdated Show resolved Hide resolved
ext/opentelemetry-ext-pymysql/setup.cfg Show resolved Hide resolved
ext/opentelemetry-ext-pymysql/setup.py Outdated Show resolved Hide resolved
MYSQL_DB_NAME = os.getenv("MYSQL_DB_NAME ", "opentelemetry-tests")


class TestFunctionalPyMysql(unittest.TestCase):
Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal Apr 20, 2020

Choose a reason for hiding this comment

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

Also here, using TestBase could help a lot.

Comment on lines +104 to +106
with self._tracer.start_as_current_span("rootSpan"), self.assertRaises(
Exception
):

Choose a reason for hiding this comment

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

I think two separated with statements would be a lot clearer in this particular case.

Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a comment

Choose a reason for hiding this comment

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

We want to add auto-instrumentation support for PyMySQL soon. I talked to @lzchen internally and we agree to merge this PR and then I could continue with the autoninstrumentation of it.
In order to unblock it, I merged some of my obvious comments, merge master and solved the conflicts, and also updated some parts to make it work with the current status (for instance, tracer_integration taking a tracer provider instead of a tracer). I'll do more changes when implementing the instrumentor interface in follow up PRs.

Copy link
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

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

The adaptation with the instrumentation class will be done later, marking it as good to go.

@@ -0,0 +1,33 @@
OpenTelemetry PyMySQL integration
===============================
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
===============================
=================================

@c24t c24t merged commit 216bd5a into open-telemetry:master Apr 24, 2020
codeboten pushed a commit to codeboten/opentelemetry-python that referenced this pull request Apr 24, 2020
Integration for PyMySQL.

Fixes some documentation as well for other db integrations. Leverages dbapi.

Co-authored-by: Mauricio Vásquez <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
instrumentation Related to the instrumentation of third party libraries or frameworks needs reviewers PRs with this label are ready for review and needs people to review to move forward.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants