Conversation
ocelotl
left a comment
There was a problem hiding this comment.
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
hectorhdzg
left a comment
There was a problem hiding this comment.
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 |
ocelotl
left a comment
There was a problem hiding this comment.
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.
| 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.
| if hasattr(self.database, "decode"): | |
| self.database = self.database.decode(errors="ignore") | |
| self.database = self.database.decode(errors="ignore") |
mauriciovasquezbernal
left a comment
There was a problem hiding this comment.
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.
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.
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.
I think two separated with statements would be a lot clearer in this particular case.
Committing some of my suggestions that are obvious.
mauriciovasquezbernal
left a comment
There was a problem hiding this comment.
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.
ocelotl
left a comment
There was a problem hiding this comment.
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.
| =============================== | |
| ================================= |
Integration for PyMySQL. Fixes some documentation as well for other db integrations. Leverages dbapi. Co-authored-by: Mauricio Vásquez <mauricio@kinvolk.io>
Integration for PyMySQL.
Fixes some documentation as well for other db integrations.
Leverages dbapi.