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

[mysqlb] Fixing missing db type #468

Merged
merged 2 commits into from
May 22, 2018
Merged

Conversation

alxch-
Copy link
Contributor

@alxch- alxch- commented May 21, 2018

The way the MySQLdb library is patched uses dbapi. Then when initializing a TracedConnection object, a new Pin was created that did not have type, that where the error came from.

This PR solves this issue and prevents from getting 2 services reported for the MySQLdb integration. If passing the pin parameter when initializing, it will not create a new one.

super(TracedConnection, self).__init__(conn)
name = _get_vendor(conn)
Pin(service=name, app=name).onto(self)
if pin and pin.enabled():

Choose a reason for hiding this comment

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

if we pass a disabled pin, we'll create a new one that is enabled. Not sure it's the right thing to do. There is an edge case that you're trying to address?

Also what if we write this code as (in case enabled() is not required):

name = _get_vendor(conn)
db_pin = pin or Pin(service=name, app=name, app_type="db")
db_pin.onto(self)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No particular reason. I'll use that.

@@ -58,6 +58,6 @@ def patch_conn(conn, *args, **kwargs):
pin = Pin(service="mysql", app="mysql", app_type="db", tags=tags)

# grab the metadata from the conn
wrapped = TracedConnection(conn)
wrapped = TracedConnection(conn, pin)

Choose a reason for hiding this comment

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

Let's use the kwarg:

wrapped = TracedConnection(conn, pin=pin)

Also can you check other mysql integrations? do they have the same issue?
If yes, let's do the same thing you did here in this PR, so that we fix all of them at once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested the other 2 mysql integrations.
pymysql was working fine.
mysql-connector had the same issue.
I patched both to be safe, tell me if it's not relevant.

if pin and pin.enabled():
pin.onto(self)
else:
Pin(service=name, app=name, app_type="db").onto(self)

Choose a reason for hiding this comment

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

instead of using db can you:

from ...ext import http, AppTypes  # from here should be the right import

Pin(service=name, app=name, app_type=AppTypes.db).onto(self)

Choose a reason for hiding this comment

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

It should be applied everywhere since we're here at this point.

@alxch- alxch- force-pushed the alex.charrier/mysql-msgpack branch from e57333c to 5f7df06 Compare May 22, 2018 14:43
@palazzem palazzem merged commit 7c5f1f9 into master May 22, 2018
@palazzem palazzem deleted the alex.charrier/mysql-msgpack branch May 22, 2018 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants