-
Notifications
You must be signed in to change notification settings - Fork 652
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
PyMySQL Integration #504
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.
A few changes requested only 👍
ext/opentelemetry-ext-dbapi/src/opentelemetry/ext/dbapi/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-pymysql/tests/test_pymysql_integration.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-pymysql/tests/test_pymysql_integration.py
Outdated
Show resolved
Hide resolved
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.
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
@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 |
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.
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", "") |
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.
self.database = self.connection_props.get("database", "") | |
self.database = self.connection_props.get("database", b"") |
if hasattr(self.database, "decode"): | ||
self.database = self.database.decode(errors="ignore") |
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.
if hasattr(self.database, "decode"): | |
self.database = self.database.decode(errors="ignore") | |
self.database = self.database.decode(errors="ignore") |
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.
Overall speaking the PR looks good.
You can address my comments before merging or we can address then in new PRs.
docs/ext/pymysql/pymysql.rst
Outdated
.. include:: ../../../ext/opentelemetry-ext-pymysql/README.rst | ||
|
||
|
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.
Currently we're not including that readme in these files anymore.
ext/opentelemetry-ext-pymysql/src/opentelemetry/ext/pymysql/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-pymysql/tests/test_pymysql_integration.py
Outdated
Show resolved
Hide resolved
MYSQL_DB_NAME = os.getenv("MYSQL_DB_NAME ", "opentelemetry-tests") | ||
|
||
|
||
class TestFunctionalPyMysql(unittest.TestCase): |
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.
Also here, using TestBase could help a lot.
with self._tracer.start_as_current_span("rootSpan"), self.assertRaises( | ||
Exception | ||
): |
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.
I think two separated with
statements would be a lot clearer in this particular case.
Committing some of my suggestions that are obvious.
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.
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.
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.
The adaptation with the instrumentation class will be done later, marking it as good to go.
@@ -0,0 +1,33 @@ | |||
OpenTelemetry PyMySQL integration | |||
=============================== |
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.
=============================== | |
================================= |
Integration for PyMySQL. Fixes some documentation as well for other db integrations. Leverages dbapi. Co-authored-by: Mauricio Vásquez <[email protected]>
Integration for PyMySQL.
Fixes some documentation as well for other db integrations.
Leverages dbapi.